简体   繁体   中英

How to test ajax with jsunit?

Did anybody write tests for ajax with jsunit? I don't now how to test asynchronous functions.

Could you please show me some examples?

Example.

I have function
var General = function() { }
General.prototype = {
limit: null,

loadData: function() {
        var url = "General.GetSessionData"
        var self = this;

        $.ajax({
            url: url,
            data: {},
            datatype: 'json',                
            success: function(data) {
                self.limit = data;
        });
    },
}

How i can test this?

Have you tried googling? HERE is an example test (asynchronous). The parent URL tells you how everything about JSUnit tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM