diff options
author | James Lal <james@lightsofapollo.com> | 2013-01-09 11:21:04 +0100 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2013-01-09 11:21:04 +0100 |
commit | ff00ab9fcaf0f791b1873ca1cd4d80e8a6dd6cda (patch) | |
tree | bf3539c61581137225f2e848f289271bd7fbb1a7 /test | |
parent | 843b96d1822a28cee8eed1776aa37b6322432249 (diff) | |
download | jsCalDAV-ff00ab9fcaf0f791b1873ca1cd4d80e8a6dd6cda.tar.gz |
utilize moz-chunked-text when given the option
Diffstat (limited to 'test')
-rw-r--r-- | test/caldav/xhr_test.js | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/test/caldav/xhr_test.js b/test/caldav/xhr_test.js index aa9b4f2..6130346 100644 --- a/test/caldav/xhr_test.js +++ b/test/caldav/xhr_test.js @@ -104,7 +104,7 @@ suite('webacls/xhr', function() { }); suite('requests real files', function() { - function request(path) { + function request(path, globalOptions) { path = 'fixtures/' + path; if (typeof(__dirname) !== 'undefined') { @@ -113,7 +113,7 @@ suite('webacls/xhr', function() { path = '/test/caldav/' + path; } - return new Xhr({ url: path }); + return new Xhr({ url: path, globalXhrOptions: globalOptions }); } test('get', function(done) { @@ -125,27 +125,56 @@ suite('webacls/xhr', function() { }); }); - test('.ondata', function(done) { - var subject = request('long.txt'); - var gotData = ''; + suite('.ondata', function() { + var expected; + var file = 'long.txt'; - subject.ondata = function(chunk) { - gotData += chunk; - }; + setup(function(done) { + if (expected) { + done(); + } + + var req = request(file); + req.send(function(err, xhr) { + expected = xhr.responseText; + done(); + }); + }); - subject.send(function(err, xhr) { - var data = xhr.responseText; + if (this.navigator && navigator.userAgent.indexOf('Mozilla') !== -1) { + test('.ondata with chunked', function(done) { + var subject = request('long.txt', { useMozChunkedText: true }); + var gotData = ''; + + subject.ondata = function(chunk) { + gotData += chunk; + }; + + var xhr = subject.send(function(err, xhr) { + assert.ok(!xhr.responseText); + assert.equal(xhr.responseType, 'moz-chunked-text'); + assert.equal(expected, gotData); + done(); + }); + }); + } - assert.equal( - data.trim(), - gotData.trim(), - 'sends ondata' - ); + test('.ondata', function(done) { + var subject = request(file); + var gotData = ''; - done(); + subject.ondata = function(chunk) { + gotData += chunk; + }; + + subject.send(function(err, xhr) { + assert.equal(expected, gotData); + done(); + }); }); - }); + + }); }); }); |