aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2013-05-10 17:25:19 -0700
committerJames Lal <james@lightsofapollo.com>2013-05-10 17:25:19 -0700
commit456913dc8b057cc44df753223e31800da62d8e98 (patch)
treed1accd27e745c36ecbe80f94375b49bc3b1b8646 /test
parent9b5dd29c45ea08ff362198ffb984492df1ebadb1 (diff)
downloadjsCalDAV-456913dc8b057cc44df753223e31800da62d8e98.tar.gz
Rework http error validation so it can be reused r=kgrandon
Diffstat (limited to 'test')
-rw-r--r--test/caldav/request/asset_test.js30
1 files changed, 22 insertions, 8 deletions
diff --git a/test/caldav/request/asset_test.js b/test/caldav/request/asset_test.js
index 3f9ebcd..a125782 100644
--- a/test/caldav/request/asset_test.js
+++ b/test/caldav/request/asset_test.js
@@ -6,6 +6,7 @@ suite('caldav/request/asset.js', function() {
// classes
var Asset;
var Xhr;
+ var Errors;
var Connection;
var SAX;
var FakeXhr;
@@ -29,6 +30,7 @@ suite('caldav/request/asset.js', function() {
FakeXhr = Caldav.require('support/fake_xhr');
Xhr = Caldav.require('xhr');
Connection = Caldav.require('connection');
+ Errors = Caldav.require('errors');
oldXhrClass = Xhr.prototype.xhrClass;
Xhr.prototype.xhrClass = FakeXhr;
@@ -82,17 +84,29 @@ suite('caldav/request/asset.js', function() {
});
- test('#put', function(done) {
- var content = 'foo';
+ suite('#put', function() {
+ test('with error', function() {
+ subject.put({}, '', function(err) {
+ assert.ok(err, 'returns error');
+ console.log(err);
+ assert.instanceOf(err, Errors.Authentication, 'assets validate http');
+ });
- subject.put({ etag: 'x' }, content, function(err, data, xhr) {
- assert.equal(xhr.openArgs[0], 'PUT');
- assert.equal(xhr.sendArgs[0], content);
- done();
+ var xhr = lastXHR();
+ xhr.respond('', 401);
});
- var xhr = lastXHR();
- xhr.respond('', 201);
+ test('success', function(done) {
+ var content = 'foo';
+ subject.put({ etag: 'x' }, content, function(err, data, xhr) {
+ assert.equal(xhr.openArgs[0], 'PUT');
+ assert.equal(xhr.sendArgs[0], content);
+ done();
+ });
+
+ var xhr = lastXHR();
+ xhr.respond('', 201);
+ });
});
test('#delete', function(done) {