diff options
author | James Lal <james@lightsofapollo.com> | 2013-01-07 08:26:13 +0100 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2013-01-07 08:38:32 +0100 |
commit | d64a1c54d6098596af1ed68272c78975ec56d0b7 (patch) | |
tree | 13a53efd31ff216fd89f7bd243ee726139824a40 /test | |
parent | 0b6e8afda0bc88fdfe0a64a15abfe537b5569bf7 (diff) | |
download | jsCalDAV-d64a1c54d6098596af1ed68272c78975ec56d0b7.tar.gz |
support for chunked responses
Diffstat (limited to 'test')
-rw-r--r-- | test/caldav/sax/dav_response_test.js | 6 | ||||
-rw-r--r-- | test/caldav/xhr_test.js | 45 |
2 files changed, 48 insertions, 3 deletions
diff --git a/test/caldav/sax/dav_response_test.js b/test/caldav/sax/dav_response_test.js index d435ef8..3825043 100644 --- a/test/caldav/sax/dav_response_test.js +++ b/test/caldav/sax/dav_response_test.js @@ -64,8 +64,10 @@ suite('caldav/sax/dav_response', function() { var event = response['event.ics']; assert.ok(event); - assert.ok(event['calendar-data'].value.name, 'name'); - assert.ok(event['calendar-data'].value.value, 'value'); + assert.ok(event['calendar-data'], 'has calendar data'); + assert.ok( + event['calendar-data'].value instanceof Array, 'ical is parsed' + ); done(); }); 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(); + }); + }); + + }); + +}); |