aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2012-07-06 14:10:11 -0700
committerJames Lal <james@lightsofapollo.com>2012-07-06 14:10:11 -0700
commit7f30ad85d5415e8fb3bbbf729ac090d453205372 (patch)
treed51ccc995aa1ad6a80df03a644bf9922bdaea289 /test
parente6fab580162a1cae2165ef88e254df284e6c7208 (diff)
downloadjsCalDAV-7f30ad85d5415e8fb3bbbf729ac090d453205372.tar.gz
Adding connection
Diffstat (limited to 'test')
-rw-r--r--test/caldav/connection_test.js69
-rw-r--r--test/caldav/index_test.js1
-rw-r--r--test/helper.js3
3 files changed, 73 insertions, 0 deletions
diff --git a/test/caldav/connection_test.js b/test/caldav/connection_test.js
new file mode 100644
index 0000000..fb32e8e
--- /dev/null
+++ b/test/caldav/connection_test.js
@@ -0,0 +1,69 @@
+testSupport.lib('xhr');
+testSupport.lib('connection');
+
+suite('caldav/connection', function() {
+
+ var subject;
+ var Connection;
+ var XHR;
+ var user = 'foo';
+ var password = 'bar';
+ var domain = 'http://foo.com';
+
+ suiteSetup(function() {
+ Connection = Caldav.require('connection');
+ XHR = Caldav.require('xhr');
+ });
+
+ setup(function() {
+ subject = new Connection({
+ user: user,
+ password: password,
+ domain: domain
+ });
+ });
+
+ suite('initialization', function() {
+
+ test('assignment', function() {
+ assert.equal(subject.user, user);
+ assert.equal(subject.password, password);
+ assert.equal(subject.domain, domain);
+ });
+
+ test('when domain has trailing slash', function() {
+ subject = new Connection({
+ domain: domain + '/'
+ });
+
+ assert.equal(subject.domain, domain, 'should remove trailing slash');
+ });
+
+ });
+
+
+ suite('request', function() {
+
+ test('credentails', function() {
+ var result = subject.request({
+ url: domain
+ });
+
+ assert.instanceOf(result, XHR);
+ assert.equal(result.url, domain);
+ assert.equal(result.password, password);
+ assert.equal(result.user, user);
+ });
+
+ test('url without domain', function() {
+ var request = subject.request({
+ url: 'bar.json'
+ });
+
+ // we add slash
+ assert.equal(request.url, domain + '/bar.json');
+ });
+
+ });
+
+});
diff --git a/test/caldav/index_test.js b/test/caldav/index_test.js
index 4fd13f8..24e45f2 100644
--- a/test/caldav/index_test.js
+++ b/test/caldav/index_test.js
@@ -28,6 +28,7 @@ suite('caldav', function() {
assert.ok(root.Request);
assert.ok(root.Templates);
assert.ok(root.Xhr);
+ assert.ok(root.Connection);
});
});
diff --git a/test/helper.js b/test/helper.js
index db3e162..07ab837 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -1,5 +1,7 @@
(function() {
+ // lazy defined navigator causes global leak warnings...
+
var requireBak;
var specialRequires = {
'chai': requireChai
@@ -13,6 +15,7 @@
/* stream hack for SAX */
if (!testSupport.isNode) {
+ window.navigator;
requireBak = require;
require = function require_shim(type) {