Mercurial > bugzilla-dashboard
comparison js/tests/test-bugzilla.js @ 69:51c1829956d9
Added mock XHR object and a simple bugzilla ajax test
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 11:41:55 -0700 |
parents | |
children | 544d339d2b4c |
comparison
equal
deleted
inserted
replaced
68:6f5b5b404066 | 69:51c1829956d9 |
---|---|
1 function testBugzillaAjax() { | |
2 var require = Require.build(); | |
3 var actual = []; | |
4 var expected = [ | |
5 ["open",["GET", | |
6 "https://api-dev.bugzilla.mozilla.org/latest/configuration"]], | |
7 ["setRequestHeader",["Accept","application/json"]], | |
8 ["setRequestHeader",["Content-Type","application/json"]], | |
9 ["addEventListener",["load",false]], | |
10 ["send",[null]] | |
11 ]; | |
12 | |
13 expect(expected.length); | |
14 | |
15 var xhr = require("mocks").xhr( | |
16 function xhrDelegate(methodName, args) { | |
17 var jsonableArgs = []; | |
18 args.forEach( | |
19 function(arg) { | |
20 if (typeof(arg) != "function") | |
21 jsonableArgs.push(arg); | |
22 }); | |
23 ; | |
24 same([methodName, jsonableArgs], expected.splice(0, 1)[0]); | |
25 }); | |
26 | |
27 var options = { | |
28 xhr: xhr, | |
29 url: "/configuration", | |
30 success: function(result) { | |
31 console.log("success!"); | |
32 } | |
33 }; | |
34 | |
35 Bugzilla.ajax(options); | |
36 } |