aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav
diff options
context:
space:
mode:
Diffstat (limited to 'test/caldav')
-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;