diff options
author | Gareth Aye <gareth.aye@gmail.com> | 2013-04-18 10:48:34 -0700 |
---|---|---|
committer | Gareth Aye <gareth.aye@gmail.com> | 2013-04-18 10:48:34 -0700 |
commit | 90940f2960050812ec0a2897a89de837066056be (patch) | |
tree | 9024ea21340ac246de43d7c467a4886dcd5d8382 /test/caldav/xhr_test.js | |
parent | c439df4388cc4bb5c1777c4dbdc5b164d5192d7f (diff) | |
parent | 5e788a0315b937ebfaea47ee15103b093bd4edb3 (diff) | |
download | jsCalDAV-90940f2960050812ec0a2897a89de837066056be.tar.gz |
Merge pull request #12 from gaye/add-xhr-abort
Add an abort routine to Caldav.Xhr
Diffstat (limited to 'test/caldav/xhr_test.js')
-rw-r--r-- | test/caldav/xhr_test.js | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/test/caldav/xhr_test.js b/test/caldav/xhr_test.js index 6130346..a3e6b66 100644 --- a/test/caldav/xhr_test.js +++ b/test/caldav/xhr_test.js @@ -76,10 +76,9 @@ suite('webacls/xhr', function() { }); suite('when xhr is a success and responds /w data', function() { - var response = '<html></html>', cb; + var response = '<html></html>', cb, xhr; setup(function(done) { - var xhr; request({ data: data, url: url, @@ -88,8 +87,8 @@ suite('webacls/xhr', function() { cb = callback.bind(this, done); xhr = subject.send(cb); - //should be waiting inbetween requests - assert.equal(subject.waiting, true); + // should be waiting inbetween requests + assert.deepEqual(subject.waiting, true); xhr.readyState = 4; xhr.responseText = response; @@ -101,6 +100,35 @@ suite('webacls/xhr', function() { }); }); + suite('when abort is called on the request', function() { + var aborted, xhr; + + setup(function() { + request({ + data: data, + url: url, + method: 'PUT' + }); + xhr = subject.send(callback); + + // should be waiting inbetween requests + assert.deepEqual(subject.waiting, true); + + aborted = false; + }); + + test('underlying request should be aborted', function(done) { + xhr.abort = function() { + aborted = true; + }; + + subject.abort(function() { + assert.deepEqual(true, aborted); + assert.deepEqual(false, subject.waiting); + done(); + }); + }); + }); }); suite('requests real files', function() { |