diff options
author | James Lal <james@lightsofapollo.com> | 2012-06-27 21:45:58 +0200 |
---|---|---|
committer | James Lal <james@lightsofapollo.com> | 2012-06-27 21:45:58 +0200 |
commit | c351e9975cee59131839bc6823e0a3e8c2a3d6cf (patch) | |
tree | dc4eb9c6861dba52daa162d5dd448e1757b2c22b /test | |
parent | f80561373584abd8b5c8a12adfa6872efc324d60 (diff) | |
download | jsCalDAV-c351e9975cee59131839bc6823e0a3e8c2a3d6cf.tar.gz |
Implemented test-agent, all tests pass node/browser
Diffstat (limited to 'test')
-rw-r--r-- | test/helper.js | 42 | ||||
-rw-r--r-- | test/webcals/ical_test.js | 1 | ||||
-rw-r--r-- | test/webcals/request/propfind_test.js | 1 | ||||
-rw-r--r-- | test/webcals/sax/base_test.js | 1 | ||||
-rw-r--r-- | test/webcals/sax_test.js | 1 |
5 files changed, 45 insertions, 1 deletions
diff --git a/test/helper.js b/test/helper.js index 5b7f178..fd66817 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,5 +1,6 @@ (function() { + var requireBak; var specialRequires = { 'chai': requireChai }; @@ -8,6 +9,21 @@ isNode: (typeof(window) === 'undefined') }; + + /* stream hack for SAX */ + + if (!testSupport.isNode) { + requireBak = require; + + require = function require_shim(type) { + if (type === 'stream') { + throw new Error('this is not node'); + } + + requireBak.apply(this, arguments); + } + } + /* cross require */ testSupport.require = function cross_require(file, callback) { @@ -15,6 +31,10 @@ return specialRequires[file](file, callback); } + if (!(/\.js$/.test(file))) { + file += '.js'; + } + if (typeof(window) === 'undefined') { var lib = require(__dirname + '/../' + file); if (typeof(callback) !== 'undefined') { @@ -43,6 +63,10 @@ testSupport.require('chai'); + if (!testSupport.isNode) { + testSupport.require('/vendor/sax'); + } + testSupport.loadSample = function(file, cb) { if (testSupport.isNode) { var root = __dirname + '/../samples/'; @@ -50,7 +74,18 @@ cb(err, contents); }); } else { - //xhr samples + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/samples/' + file, true); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status !== 200) { + cb(new Error('file not found or other error', xhr)); + } else { + cb(null, xhr.responseText); + } + } + } + xhr.send(null); } }; @@ -90,10 +125,15 @@ } requireRequest = function(callback) { + testSupport.lib('responder'); testSupport.lib('xhr'); testSupport.lib('sax'); + testSupport.lib('sax/base'); + testSupport.lib('sax/dav_response'); testSupport.lib('request/abstract'); testSupport.lib('template'); + testSupport.lib('templates/calendar_data'); + testSupport.lib('templates/calendar_filter'); testSupport.helper('fake_xhr'); //in the future we need a callback for browser support. diff --git a/test/webcals/ical_test.js b/test/webcals/ical_test.js index 3ff1dc3..7e424f3 100644 --- a/test/webcals/ical_test.js +++ b/test/webcals/ical_test.js @@ -5,6 +5,7 @@ suite('webcals/ics', function() { var ical; suiteSetup(function() { + console.log(Webcals); ical = Webcals.require('ical'); }); diff --git a/test/webcals/request/propfind_test.js b/test/webcals/request/propfind_test.js index 609cc82..ea6f080 100644 --- a/test/webcals/request/propfind_test.js +++ b/test/webcals/request/propfind_test.js @@ -1,4 +1,5 @@ requireRequest(); +testSupport.lib('request/propfind'); suite('webcals/request/propfind', function() { var Abstract, diff --git a/test/webcals/sax/base_test.js b/test/webcals/sax/base_test.js index cdd8379..7ccc5da 100644 --- a/test/webcals/sax/base_test.js +++ b/test/webcals/sax/base_test.js @@ -1,3 +1,4 @@ +testSupport.lib('responder'); testSupport.lib('sax'); testSupport.lib('sax/base'); diff --git a/test/webcals/sax_test.js b/test/webcals/sax_test.js index 7924c0a..0ddd4bc 100644 --- a/test/webcals/sax_test.js +++ b/test/webcals/sax_test.js @@ -1,3 +1,4 @@ +testSupport.lib('responder'); testSupport.lib('sax'); testSupport.lib('sax/base'); |