equal
deleted
inserted
replaced
24 |
24 |
25 QUnit.test('test simple h1 inclusion (ajax_url0.html)', function (assert) { |
25 QUnit.test('test simple h1 inclusion (ajax_url0.html)', function (assert) { |
26 assert.expect(3); |
26 assert.expect(3); |
27 assert.equal($('#qunit-fixture').children().length, 0); |
27 assert.equal($('#qunit-fixture').children().length, 0); |
28 var done = assert.async(); |
28 var done = assert.async(); |
29 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html') |
29 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html', null, 'GET') |
30 .addCallback(function() { |
30 .addCallback(function() { |
31 try { |
31 try { |
32 assert.equal($('#qunit-fixture').children().length, 1); |
32 assert.equal($('#qunit-fixture').children().length, 1); |
33 assert.equal($('#qunit-fixture h1').html(), 'Hello'); |
33 assert.equal($('#qunit-fixture h1').html(), 'Hello'); |
34 } finally { |
34 } finally { |
41 QUnit.test('test simple html head inclusion (ajax_url1.html)', function (assert) { |
41 QUnit.test('test simple html head inclusion (ajax_url1.html)', function (assert) { |
42 assert.expect(6); |
42 assert.expect(6); |
43 var scriptsIncluded = jsSources(); |
43 var scriptsIncluded = jsSources(); |
44 assert.equal(jQuery.inArray('http://foo.js', scriptsIncluded), - 1); |
44 assert.equal(jQuery.inArray('http://foo.js', scriptsIncluded), - 1); |
45 var done = assert.async(); |
45 var done = assert.async(); |
46 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url1.html') |
46 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url1.html', null, 'GET') |
47 .addCallback(function() { |
47 .addCallback(function() { |
48 try { |
48 try { |
49 var origLength = scriptsIncluded.length; |
49 var origLength = scriptsIncluded.length; |
50 scriptsIncluded = jsSources(); |
50 scriptsIncluded = jsSources(); |
51 // check that foo.js has been prepended to <head> |
51 // check that foo.js has been prepended to <head> |
64 |
64 |
65 QUnit.test('test addCallback', function (assert) { |
65 QUnit.test('test addCallback', function (assert) { |
66 assert.expect(3); |
66 assert.expect(3); |
67 assert.equal($('#qunit-fixture').children().length, 0); |
67 assert.equal($('#qunit-fixture').children().length, 0); |
68 var done = assert.async(); |
68 var done = assert.async(); |
69 var d = $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html'); |
69 var d = $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html', null, 'GET'); |
70 d.addCallback(function() { |
70 d.addCallback(function() { |
71 try { |
71 try { |
72 assert.equal($('#qunit-fixture').children().length, 1); |
72 assert.equal($('#qunit-fixture').children().length, 1); |
73 assert.equal($('#qunit-fixture h1').html(), 'Hello'); |
73 assert.equal($('#qunit-fixture h1').html(), 'Hello'); |
74 } finally { |
74 } finally { |
103 |
103 |
104 QUnit.test('test addCallback with parameters', function (assert) { |
104 QUnit.test('test addCallback with parameters', function (assert) { |
105 assert.expect(3); |
105 assert.expect(3); |
106 assert.equal($('#qunit-fixture').children().length, 0); |
106 assert.equal($('#qunit-fixture').children().length, 0); |
107 var done = assert.async(); |
107 var done = assert.async(); |
108 var d = $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html'); |
108 var d = $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html', null, 'GET'); |
109 d.addCallback(function(data, req, arg1, arg2) { |
109 d.addCallback(function(data, req, arg1, arg2) { |
110 try { |
110 try { |
111 assert.equal(arg1, 'Hello'); |
111 assert.equal(arg1, 'Hello'); |
112 assert.equal(arg2, 'world'); |
112 assert.equal(arg2, 'world'); |
113 } finally { |
113 } finally { |
153 }); |
153 }); |
154 |
154 |
155 QUnit.test('test addErrback', function (assert) { |
155 QUnit.test('test addErrback', function (assert) { |
156 assert.expect(1); |
156 assert.expect(1); |
157 var done = assert.async(); |
157 var done = assert.async(); |
158 var d = $('#qunit-fixture').loadxhtml('static/jstests/nonexistent.html'); |
158 var d = $('#qunit-fixture').loadxhtml('static/jstests/nonexistent.html', null, 'GET'); |
159 d.addCallback(function() { |
159 d.addCallback(function() { |
160 // should not be executed |
160 // should not be executed |
161 assert.ok(false, "callback is executed"); |
161 assert.ok(false, "callback is executed"); |
162 }); |
162 }); |
163 d.addErrback(function() { |
163 d.addErrback(function() { |
171 |
171 |
172 QUnit.test('test callback execution order', function (assert) { |
172 QUnit.test('test callback execution order', function (assert) { |
173 assert.expect(3); |
173 assert.expect(3); |
174 var counter = 0; |
174 var counter = 0; |
175 var done = assert.async(); |
175 var done = assert.async(); |
176 var d = $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html'); |
176 var d = $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html', null, 'GET'); |
177 d.addCallback(function() { |
177 d.addCallback(function() { |
178 assert.equal(++counter, 1); // should be executed first |
178 assert.equal(++counter, 1); // should be executed first |
179 }); |
179 }); |
180 d.addCallback(function() { |
180 d.addCallback(function() { |
181 assert.equal(++counter, 2); |
181 assert.equal(++counter, 2); |
196 assert.equal(jQuery.inArray('http://foo.js', scriptsIncluded), -1); |
196 assert.equal(jQuery.inArray('http://foo.js', scriptsIncluded), -1); |
197 assert.equal($('head link').length, 1); |
197 assert.equal($('head link').length, 1); |
198 /* use endswith because in pytest context we have an absolute path */ |
198 /* use endswith because in pytest context we have an absolute path */ |
199 assert.ok($('head link').attr('href').endswith('/qunit.css'), 'qunit.css is loaded'); |
199 assert.ok($('head link').attr('href').endswith('/qunit.css'), 'qunit.css is loaded'); |
200 var done = assert.async(); |
200 var done = assert.async(); |
201 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url1.html') |
201 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url1.html', null, 'GET') |
202 .addCallback(function() { |
202 .addCallback(function() { |
203 var origLength = scriptsIncluded.length; |
203 var origLength = scriptsIncluded.length; |
204 scriptsIncluded = jsSources(); |
204 scriptsIncluded = jsSources(); |
205 try { |
205 try { |
206 // check that foo.js has been inserted in <head> |
206 // check that foo.js has been inserted in <head> |
233 var events = null; |
233 var events = null; |
234 $(CubicWeb).bind('server-response', function() { |
234 $(CubicWeb).bind('server-response', function() { |
235 // check that server-response event on CubicWeb is triggered |
235 // check that server-response event on CubicWeb is triggered |
236 events = 'CubicWeb'; |
236 events = 'CubicWeb'; |
237 }); |
237 }); |
238 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html') |
238 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html', null, 'GET') |
239 .addCallback(function() { |
239 .addCallback(function() { |
240 try { |
240 try { |
241 assert.equal(events, 'CubicWeb'); |
241 assert.equal(events, 'CubicWeb'); |
242 } finally { |
242 } finally { |
243 done(); |
243 done(); |
254 nodes.push('node'); |
254 nodes.push('node'); |
255 }); |
255 }); |
256 $(CubicWeb).bind('server-response', function() { |
256 $(CubicWeb).bind('server-response', function() { |
257 nodes.push('CubicWeb'); |
257 nodes.push('CubicWeb'); |
258 }); |
258 }); |
259 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html') |
259 $('#qunit-fixture').loadxhtml('static/jstests/ajax_url0.html', null, 'GET') |
260 .addCallback(function() { |
260 .addCallback(function() { |
261 try { |
261 try { |
262 assert.equal(nodes.length, 2); |
262 assert.equal(nodes.length, 2); |
263 // check that server-response event on CubicWeb is triggered |
263 // check that server-response event on CubicWeb is triggered |
264 // only once and event server-response on node is triggered |
264 // only once and event server-response on node is triggered |