aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/xhr_test.js
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2012-07-23 22:37:40 -0700
committerJames Lal <james@lightsofapollo.com>2012-07-23 22:37:40 -0700
commit585956e08bb7afaa3001684e7a65bf462d7acaaa (patch)
treef6b5607cf116acf437e2d5da6e8e80e8d0c2dd5c /test/caldav/xhr_test.js
parent2a138899fd6cb44256f7b31765bbe8e52508df1a (diff)
downloadjsCalDAV-585956e08bb7afaa3001684e7a65bf462d7acaaa.tar.gz
xhr fixes for firefox
Diffstat (limited to 'test/caldav/xhr_test.js')
-rw-r--r--test/caldav/xhr_test.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/caldav/xhr_test.js b/test/caldav/xhr_test.js
index 1082958..c71dc12 100644
--- a/test/caldav/xhr_test.js
+++ b/test/caldav/xhr_test.js
@@ -49,6 +49,21 @@ suite('webacls/xhr', function() {
});
});
+ test('#_credentials', function() {
+ // don't run this in node
+ if (typeof(window) === 'undefined') {
+ return;
+ }
+
+ var user = 'james';
+ var password = 'lal';
+ var expected = 'Basic ' + window.btoa(user + ':' + password);
+
+ assert.equal(
+ subject._credentials(user, password), expected
+ );
+ });
+
suite('.abort', function() {
suite('when there is an xhr object', function() {
var aborted;
@@ -121,6 +136,34 @@ suite('webacls/xhr', function() {
responseXhr = null;
});
+ test('with mozSystem', function() {
+ var user = 'user';
+ var password = 'pass';
+ var url = '/foo';
+
+ request({
+ globalXhrOptions: { mozSystem: true },
+ user: user,
+ password: password,
+ method: 'GET',
+ url: url
+ });
+
+
+ subject.send(function() {});
+ var args = subject.xhr.openArgs;
+
+ assert.deepEqual(
+ args,
+ ['GET', url, true]
+ );
+
+ assert.equal(
+ subject.xhr.headers['Authorization'],
+ subject._credentials(user, password)
+ );
+ });
+
suite('when xhr is a success and responds /w data', function() {
var response = '<html></html>', cb;