forked from jquery/jquery-migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.js
72 lines (64 loc) · 1.5 KB
/
ajax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module("ajax");
// Can't run this in PhantomJS because it's a local file
if ( window.location.protocol !== "file:" ) {
test( "jQuery.ajax() with empty JSON string", function() {
expect( 2 );
stop();
jQuery.migrateReset();
jQuery.ajax({
url: "data/empty.json",
dataType: "json",
cache: false,
success: function( data ) {
equal( data, null, "empty string converted to null" );
equal( jQuery.migrateWarnings.length, 1, "warned" );
},
error: function( xhr, msg ) {
ok( false, "error: "+ msg );
},
complete: function() {
start();
}
});
});
test( "jQuery.ajax() with 'null' JSON string", function() {
expect( 2 );
stop();
jQuery.migrateReset();
jQuery.ajax({
url: "data/null.json",
dataType: "json",
cache: false,
success: function( data ) {
equal( data, null, "'null' converted to null" );
equal( jQuery.migrateWarnings.length, 0, "did not warn" );
},
error: function( xhr, msg ) {
ok( false, "error: "+ msg );
},
complete: function() {
start();
}
});
});
test( "jQuery.ajax() with simple JSON string", function() {
expect( 2 );
stop();
jQuery.migrateReset();
jQuery.ajax({
url: "data/simple.json",
dataType: "json",
cache: false,
success: function( data ) {
equal( data.gibson, 42, "right answer" );
equal( jQuery.migrateWarnings.length, 0, "did not warn" );
},
error: function( xhr, msg ) {
ok( false, "error: "+ msg );
},
complete: function() {
start();
}
});
});
}