aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Aye <gaye@mozilla.com>2013-04-29 09:50:15 -0700
committerGareth Aye <gaye@mozilla.com>2013-04-29 09:50:15 -0700
commit9b6e2c616154f2c20fe6272dca083868c02f98f4 (patch)
treeadfd0334e29bb33ae170e8040162e606681ea260
parent90940f2960050812ec0a2897a89de837066056be (diff)
parent8340549fa7c16e682936b0da26f65671c91311d5 (diff)
downloadjsCalDAV-9b6e2c616154f2c20fe6272dca083868c02f98f4.tar.gz
Merge pull request #13 from mozilla-b2g/caldav-sinon
Test framework refactorng + sinon
-rw-r--r--Makefile5
-rw-r--r--package.json7
-rw-r--r--test-agent/index.html4
-rw-r--r--test-agent/index.js2
-rw-r--r--test-agent/sandbox.html2
-rw-r--r--test/helper.js20
6 files changed, 26 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 7393e74..a1c500f 100644
--- a/Makefile
+++ b/Makefile
@@ -9,12 +9,7 @@ package: test-agent-config
rm -f $(WEB_FILE)
touch $(WEB_FILE)
mkdir $(VENDOR)
- cp ./node_modules/mocha/mocha.js $(VENDOR)
- cp ./node_modules/mocha/mocha.css $(VENDOR)
- cp ./node_modules/chai/chai.js $(VENDOR)
cp ./lib/sax.js $(VENDOR)
- cp ./node_modules/test-agent/test-agent.js $(VENDOR)
- cp ./node_modules/test-agent/test-agent.css $(VENDOR)
echo '/* sax js - LICENSE: https://github.com/isaacs/sax-js/blob/master/LICENSE */' >> $(WEB_FILE)
cat $(VENDOR)/sax.js >> $(WEB_FILE);
diff --git a/package.json b/package.json
index 934f6de..da7a041 100644
--- a/package.json
+++ b/package.json
@@ -19,11 +19,12 @@
},
"devDependencies": {
"debug": "~0.7",
- "mocha": "~1.1",
+ "mocha": "~1.7",
"chai": "~1.0",
- "test-agent": "~0.6",
+ "test-agent": "~0.10",
"http-proxy": "~0.8",
- "commander": "~1.0"
+ "commander": "~1.0",
+ "sinon": "~1.6"
},
"license": "MIT",
"engine": {
diff --git a/test-agent/index.html b/test-agent/index.html
index b2e7bb5..d2835d0 100644
--- a/test-agent/index.html
+++ b/test-agent/index.html
@@ -4,7 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Serve the tests</title>
- <link rel="stylesheet" href="../vendor/test-agent.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="/node_modules/test-agent/test-agent.css" type="text/css" charset="utf-8">
<style type="text/css" media="all">
body > iframe {
width: 100%;
@@ -21,7 +21,7 @@
</div>
<!-- Load the bare minimum to get the ui and runner working -->
-<script src="../vendor/test-agent.js" type="text/javascript" charset="utf-8"></script>
+<script src="/node_modules/test-agent/test-agent.js" type="text/javascript" charset="utf-8"></script>
<script src="./index.js" type="text/javascript" charset="utf-8"></script>
</body>
diff --git a/test-agent/index.js b/test-agent/index.js
index f5b1a9a..0f865df 100644
--- a/test-agent/index.js
+++ b/test-agent/index.js
@@ -12,7 +12,7 @@
worker.use(TestAgent.BrowserWorker.MochaDriver, {
/* path to mocha */
- mochaUrl: '../vendor/mocha.js',
+ mochaUrl: '/node_modules/mocha/mocha.js',
testHelperUrl: '../test/helper.js',
reporter: 'HTML',
ui: 'tdd'
diff --git a/test-agent/sandbox.html b/test-agent/sandbox.html
index 8b8fb94..fa79ac3 100644
--- a/test-agent/sandbox.html
+++ b/test-agent/sandbox.html
@@ -3,7 +3,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Tests</title>
- <link rel="stylesheet" type="text/css" href="../vendor/mocha.css" />
+ <link rel="stylesheet" type="text/css" href="/node_modules/mocha/mocha.css" />
<style type="text/css" media="all">
iframe {
border: none;
diff --git a/test/helper.js b/test/helper.js
index df0c6d9..2a8c772 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -11,7 +11,6 @@
isNode: (typeof(window) === 'undefined')
};
-
/* stream hack for SAX */
if (!testSupport.isNode) {
@@ -48,6 +47,23 @@
}
}
+ /* sinon */
+ if (testSupport.isNode) {
+ global.sinon = require('sinon');
+ } else {
+ window.require('/node_modules/sinon/pkg/sinon.js');
+ }
+
+ setup(function() {
+ this.sinon = sinon.sandbox.create();
+ });
+
+ teardown(function() {
+ this.sinon.restore();
+ });
+
+ /* chai */
+
function setupChai(chai) {
chai.Assertion.includeStack = true;
assert = chai.assert;
@@ -58,7 +74,7 @@
if (testSupport.isNode) {
setupChai(require('chai'));
} else {
- require('/vendor/chai.js', function() {
+ require('/node_modules/chai/chai.js', function() {
setupChai(chai);
});
}