aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/xhr_test.js
diff options
context:
space:
mode:
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();
+ });
+ });
+
+ });
+
+});