aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/request/asset_test.js
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2013-05-10 17:33:00 -0700
committerJames Lal <james@lightsofapollo.com>2013-05-10 17:33:00 -0700
commit09d9ad3f92edec992bd1ab2e6a1c505f16bf22de (patch)
treed8c5b306760c9de5359aafe428753a4f3326c7a5 /test/caldav/request/asset_test.js
parent9b5dd29c45ea08ff362198ffb984492df1ebadb1 (diff)
parent5f35b858c31d455894f3c700eade1d1ca0ca4d3a (diff)
downloadjsCalDAV-09d9ad3f92edec992bd1ab2e6a1c505f16bf22de.tar.gz
Merge pull request #17 from lightsofapollo/asset-http-status-checks
Rework http error validation so it can be reused r=kgrandon
Diffstat (limited to 'test/caldav/request/asset_test.js')
-rw-r--r--test/caldav/request/asset_test.js29
1 files changed, 21 insertions, 8 deletions
diff --git a/test/caldav/request/asset_test.js b/test/caldav/request/asset_test.js
index 3f9ebcd..f1878ba 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,28 @@ 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');
+ 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) {