jeudi 11 février 2021

Unity Test for line of code in javascript

I do not how create Unity Test for this code. Anyone could help me write od give advice some simple tests for this part of the code? (I wrote this code in pure JavaScript and jQuery)

function getFunction(movie) {

axios.get(url + 's=' + movie + "&apikey=" + APIkey)

.then(function (response) {
    console.log(response);

    let a = response.data.Search;

    let b= '';
    $.each(a, (index, mainValue) => {

        b+= `

    <div class="container">
        <div class="row">
            <div class="col-md-6 text-center">

                <div>
                    <ul>
                    <li <p>Movie or Series: ${mainValue.Type}</p></li>
                    </ul>
                </div>
                <a href="http://imdb.com/title/${mainValue.imdbID}" target="_blank" class="btn btn-primary">View</a>

            </div>

            <div>
                <img src="${mainValue.Poster}">
            </div>
        </div>
    </div>

        `;
    });

    $('#content').html(b);

})

.catch(function (error) {
    if (error.response) {
        console.log(error.response.data);

    } else {
        console.log('Error', error.message);
    }
    console.log(error);
})

How can I test the rest of the code?

Aucun commentaire:

Enregistrer un commentaire