aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/xhr_test.js
diff options
context:
space:
mode:
authorJames Lal <james@lightsofapollo.com>2013-01-07 05:16:42 -0800
committerJames Lal <james@lightsofapollo.com>2013-01-07 05:16:42 -0800
commit3f8833038d337d2840dc7ca06ddcb8c26a21bd14 (patch)
treebdb1dece706b0a2a4b5a0b8442a1bffc45fc794f /test/caldav/xhr_test.js
parent0b6e8afda0bc88fdfe0a64a15abfe537b5569bf7 (diff)
parent3170505852bbb6379a712ff816e1715f512516ad (diff)
downloadjsCalDAV-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.js45
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();
+ });
+ });
+
+ });
+
+});