diff options
author | James Lal <james@lightsofapollo.com> | 2013-01-07 05:16:42 -0800 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2013-01-07 05:16:42 -0800 |
commit | 3f8833038d337d2840dc7ca06ddcb8c26a21bd14 (patch) | |
tree | bdb1dece706b0a2a4b5a0b8442a1bffc45fc794f /test/caldav/xhr_test.js | |
parent | 0b6e8afda0bc88fdfe0a64a15abfe537b5569bf7 (diff) | |
parent | 3170505852bbb6379a712ff816e1715f512516ad (diff) | |
download | jsCalDAV-3f8833038d337d2840dc7ca06ddcb8c26a21bd14.tar.gz |
Merge pull request #8 from mozilla-b2g/progress-events
Progress events
Diffstat (limited to 'test/caldav/xhr_test.js')
-rw-r--r-- | test/caldav/xhr_test.js | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/test/caldav/xhr_test.js b/test/caldav/xhr_test.js index 0d6d7fb..fdcbe37 100644 --- a/test/caldav/xhr_test.js +++ b/test/caldav/xhr_test.js @@ -202,6 +202,49 @@ suite('webacls/xhr', function() { }); -}); + suite('requests real files', function() { + function request(path) { + path = 'fixtures/' + path; + + if (typeof(__dirname) !== 'undefined') { + path = 'file://' + __dirname + '/' + path; + } else { + path = '/test/caldav/' + path; + } + + return new Xhr({ url: path }); + } + + test('get', function(done) { + subject = request('file.txt'); + subject.send(function(err, xhr) { + var data = xhr.responseText; + assert.equal(data.trim(), 'file'); + done(); + }); + }); + + test('.ondata', function(done) { + var subject = request('long.txt'); + var gotData = ''; + subject.ondata = function(chunk) { + gotData += chunk; + }; + subject.send(function(err, xhr) { + var data = xhr.responseText; + + assert.equal( + data.trim(), + gotData.trim(), + 'sends ondata' + ); + + done(); + }); + }); + + }); + +}); |