mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Tests: update AJAX tests
* IE8 support for makeAjaxRequest test (xhr.response does not exist, responseText is supported by all major browsers) * Update makeAjaxRequest test to confirm that the success callback is called and that the error callback is not * Add a test for makeAjaxRequest with an invalid file and verify that error callback is called but the success callback is not
This commit is contained in:
parent
6d7dd71577
commit
3434fe600c
@ -1,3 +1,5 @@
|
||||
/* global module, asyncTest, $, ok, equal, strictEqual, notEqual, start, test, Util, testLog */
|
||||
|
||||
(function() {
|
||||
|
||||
module("utils");
|
||||
@ -56,10 +58,33 @@
|
||||
asyncTest("makeAjaxRequest", function() {
|
||||
var timeWatcher = Util.timeWatcher();
|
||||
|
||||
OpenSeadragon.makeAjaxRequest('data/testpattern.dzi', function(xhr) {
|
||||
ok(/deepzoom/.test(xhr.response), 'file loaded');
|
||||
OpenSeadragon.makeAjaxRequest('data/testpattern.dzi',
|
||||
function(xhr) {
|
||||
equal(xhr.status, 200, 'Success callback called for HTTP 200');
|
||||
ok(/deepzoom/.test(xhr.responseText), 'Success function called');
|
||||
timeWatcher.done();
|
||||
},
|
||||
function(xhr) {
|
||||
ok(false, 'Error callback should not be called');
|
||||
timeWatcher.done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
asyncTest("makeAjaxRequest for invalid file", function() {
|
||||
var timeWatcher = Util.timeWatcher();
|
||||
|
||||
OpenSeadragon.makeAjaxRequest('not-a-real-dzi-file',
|
||||
function(xhr) {
|
||||
ok(false, 'Success function should not be called for errors');
|
||||
timeWatcher.done();
|
||||
},
|
||||
function(xhr) {
|
||||
equal(xhr.status, 404, 'Error callback called for HTTP 404');
|
||||
ok(true, 'Error function should be called for errors');
|
||||
timeWatcher.done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// ----------
|
||||
|
Loading…
Reference in New Issue
Block a user