0

Can somebody please tell me whether we need to use asyncTest() to test the synchronous ajax calls or test() can be used without start() and stop().

Consider this:

var Class= function () {
var init = function () {

    amplify.request.define('students', 'ajax', {
        url: '/methods/GetStudentsList',
        dataType: 'json',
        type: 'GET',
        async:false

    });
};

Students = function (branch, callback) {
    init();
    return amplify.request("students",
        { branchID: branch },
        callback.success,
        callback.error
    );
};

return {
    Students: Students
};
} ();

How can we write test cases for Class.Students() method when the 'async' property is 'true' and 'false' ?

0

1 Answer 1

0

with asyncTest and asnyc true or false:

asyncTest("test", function () {
    init.Students(someBranch, function (a, b, c) {
        ok(true); //add your tests here
        start();
    });
});

with test and stop/start:

   test("test", function () {
        stop();
        init.Students(someBranch, function (a, b, c) {
            ok(true); //add your tests here
            start();
        });
    });

note that your requests will be handled async by qunit in both cases

using test without start nor stop will probably let your tests fail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.