diff options
Diffstat (limited to 'test/caldav')
-rw-r--r-- | test/caldav/request/asset_test.js | 29 |
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) { |