aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile14
-rw-r--r--lib/webcals/ical.js2
-rw-r--r--lib/webcals/request/propfind.js2
-rw-r--r--lib/webcals/sax.js4
-rw-r--r--test-agent/config.json2
-rw-r--r--test-agent/index.js3
-rw-r--r--test/helper.js42
-rw-r--r--test/webcals/ical_test.js1
-rw-r--r--test/webcals/request/propfind_test.js1
-rw-r--r--test/webcals/sax/base_test.js1
-rw-r--r--test/webcals/sax_test.js1
11 files changed, 63 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 29ee741..6771c76 100644
--- a/Makefile
+++ b/Makefile
@@ -9,11 +9,19 @@ package: test-agent-config
cp ./node_modules/mocha/mocha.js $(VENDOR)
cp ./node_modules/mocha/mocha.css $(VENDOR)
cp ./node_modules/chai/chai.js $(VENDOR)
+ cp ./node_modules/sax/lib/sax.js $(VENDOR)
cp ./node_modules/test-agent/test-agent.js $(VENDOR)
cp ./node_modules/test-agent/test-agent.css $(VENDOR)
-.PHONY: test
-test:
+
+test: test-node test-browser
+
+.PHONY: test-browser
+test-browser:
+ ./node_modules/test-agent/bin/js-test-agent test --reporter Spec
+
+.PHONY: test-node
+test-node:
./node_modules/mocha/bin/mocha \
--ui tdd \
--reporter $(REPORTER) \
@@ -32,7 +40,7 @@ test-agent-config:
# Build json array of all test files
for d in test; \
do \
- find $$d -name '*_test.js' | sed "s:$$d/::g" >> /tmp/test-agent-config; \
+ find $$d -name '*_test.js' | sed "s:$$d/:/$$d/:g" >> /tmp/test-agent-config; \
done;
@echo '{"tests": [' >> $(TEST_AGENT_CONFIG)
@cat /tmp/test-agent-config | \
diff --git a/lib/webcals/ical.js b/lib/webcals/ical.js
index 45cef83..797e40b 100644
--- a/lib/webcals/ical.js
+++ b/lib/webcals/ical.js
@@ -133,7 +133,7 @@
}.apply(
this,
(this.Webcals) ?
- [Webcals('ics'), Webcals] :
+ [Webcals('ical'), Webcals] :
[module, require('./webcals')]
));
diff --git a/lib/webcals/request/propfind.js b/lib/webcals/request/propfind.js
index e5f6f26..a4edd16 100644
--- a/lib/webcals/request/propfind.js
+++ b/lib/webcals/request/propfind.js
@@ -64,6 +64,6 @@
}.apply(
this,
(this.Webcals) ?
- [Webcals('request/abstract'), Webcals] :
+ [Webcals('request/propfind'), Webcals] :
[module, require('../webcals')]
));
diff --git a/lib/webcals/sax.js b/lib/webcals/sax.js
index d6f7592..8a24ecf 100644
--- a/lib/webcals/sax.js
+++ b/lib/webcals/sax.js
@@ -2,7 +2,7 @@
var Responder = ns.require('responder');
- if (typeof(sax) === 'undefined') {
+ if (typeof(window) === 'undefined') {
Parser.sax = require('sax');
} else {
Parser.sax = sax;
@@ -215,6 +215,6 @@
}.apply(
this,
(this.Webcals) ?
- [Webcals('xml_parser'), Webcals] :
+ [Webcals('sax'), Webcals] :
[module, require('./webcals')]
));
diff --git a/test-agent/config.json b/test-agent/config.json
index f4f0f2a..f142f4c 100644
--- a/test-agent/config.json
+++ b/test-agent/config.json
@@ -1,3 +1,3 @@
{"tests": [
-"webcals/ical_test.js","webcals/request/abstract_test.js","webcals/request/calendar_query_test.js","webcals/request/propfind_test.js","webcals/resource_root_test.js","webcals/sax/base_test.js","webcals/sax/dav_response_test.js","webcals/sax_test.js","webcals/template_test.js","webcals/templates/calendar_data_test.js","webcals/templates/calendar_filter_test.js","webcals/xhr_test.js"
+"/test/webcals/ical_test.js","/test/webcals/request/abstract_test.js","/test/webcals/request/calendar_query_test.js","/test/webcals/request/propfind_test.js","/test/webcals/resource_root_test.js","/test/webcals/sax/base_test.js","/test/webcals/sax/dav_response_test.js","/test/webcals/sax_test.js","/test/webcals/template_test.js","/test/webcals/templates/calendar_data_test.js","/test/webcals/templates/calendar_filter_test.js","/test/webcals/xhr_test.js"
]}
diff --git a/test-agent/index.js b/test-agent/index.js
index 637062b..f5b1a9a 100644
--- a/test-agent/index.js
+++ b/test-agent/index.js
@@ -14,7 +14,8 @@
/* path to mocha */
mochaUrl: '../vendor/mocha.js',
testHelperUrl: '../test/helper.js',
- reporter: 'HTML'
+ reporter: 'HTML',
+ ui: 'tdd'
});
worker.use(TestAgent.BrowserWorker.Websocket);
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');