Mercurial > bugzilla-dashboard
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/tests/test-bugzilla.js Sun Apr 25 11:41:55 2010 -0700 @@ -0,0 +1,36 @@ +function testBugzillaAjax() { + var require = Require.build(); + var actual = []; + var expected = [ + ["open",["GET", + "https://api-dev.bugzilla.mozilla.org/latest/configuration"]], + ["setRequestHeader",["Accept","application/json"]], + ["setRequestHeader",["Content-Type","application/json"]], + ["addEventListener",["load",false]], + ["send",[null]] + ]; + + expect(expected.length); + + var xhr = require("mocks").xhr( + function xhrDelegate(methodName, args) { + var jsonableArgs = []; + args.forEach( + function(arg) { + if (typeof(arg) != "function") + jsonableArgs.push(arg); + }); + ; + same([methodName, jsonableArgs], expected.splice(0, 1)[0]); + }); + + var options = { + xhr: xhr, + url: "/configuration", + success: function(result) { + console.log("success!"); + } + }; + + Bugzilla.ajax(options); +}