>> How to spyon a an Ajax call and load response text by own yourself instead of server.
> here's the code with explanation....
spyOn(Ext.Ajax, 'request').andCallFake(function (request) { request.success = 'true'; // as when server loads response its success is true but here we have to make success true by ourself only... // this callback is loading response(defined above) in into the store instead of loading a an actual reponse from server request.callback(null, true, response); }); mainList = Ext.create('Screener.store.Patients'); // creation of store will call Ajax request and from here spyon works. // you may have created mainList above in describe, but here also its needed for Ajax call |
---|
...
now you can check if the data in mainList is the same as what you have hardcoded in responseText |
---|