Permalink
Browse files

updated unit tests to use mocha

  • Loading branch information...
1 parent 7495821 commit 10b79d3fb60aa0af3ce1d58361784aaeaf58cfe7 @jgallen23 committed Mar 30, 2012
Showing with 379 additions and 1,934 deletions.
  1. +2 −6 Makefile
  2. +2 −1 package.json
  3. +23 −0 test/index.html
  4. +0 −239 test/node/resistance.test.js
  5. +352 −0 test/resistance.test.js
  6. +0 −1,437 test/web/ender.js
  7. +0 −8 test/web/ender.min.js
  8. +0 −11 test/web/example.html
  9. +0 −232 test/web/live.js
View
@@ -1,11 +1,7 @@
boosh:
- ./node_modules/.bin/smoosh make build.json
+ @./node_modules/.bin/smoosh make build.json
test:
- ./node_modules/.bin/nodeunit test/node/resistance.test.js
-
-# requires npm >= 1.0.0
-install:
- npm install smoosh
+ @./node_modules/.bin/mocha -R list
.PHONY: test
View
@@ -9,7 +9,8 @@
"url": "https://github.com/jgallen23/resistance.git"
},
"devDependencies": {
- "nodeunit": "*",
+ "mocha": "*",
+ "chai": "*",
"smoosh": "*"
},
"main": "./dist/resistance.js",
View
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Mocha Tests</title>
+ <link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script src="../node_modules/chai/chai.js"></script>
+ <script src="../node_modules/mocha/mocha.js"></script>
+ <script>mocha.setup('bdd')</script>
+ <script src="../dist/resistance.js"></script>
+ <script src="resistance.test.js"></script>
+ <script>
+ $(function () {
+ mocha
+ .run()
+ })
+ </script>
+</head>
+<body>
+ <div id="mocha"></div>
+</body>
+</html>
@@ -1,239 +0,0 @@
-var R = require("../../");
-
-exports.seriesTest = function(t) {
- var testsRun = 0;
- R.series([
- function(callback) {
- t.equal(testsRun, 0);
- setTimeout(function() {
- testsRun++;
- callback(1);
- }, 200);
- },
- function(callback) {
- t.equal(testsRun, 1);
- setTimeout(function() {
- testsRun++;
- callback(2);
- }, 100);
- }
- ], function(data) {
- t.equal(data[0], 1);
- t.equal(data[1], 2);
- t.equal(testsRun, 2);
- t.done();
- });
-};
-
-exports.seriesSyncTest = function(t) {
- R.series([
- function(callback) {
- callback(1);
- },
- function(callback) {
- callback(2);
- }
- ], function(data) {
- t.equal(data[0], 1);
- t.equal(data[1], 2);
- t.done();
- });
-};
-
-exports.testParallel = function(t) {
- var testsRun = 0;
- R.parallel([
- function(callback) {
- t.equal(testsRun, 0);
- setTimeout(function() {
- testsRun++;
- callback(1);
- }, 200);
- },
- function(callback) {
- t.equal(testsRun, 0);
- setTimeout(function() {
- testsRun++;
- callback(2);
- }, 100);
- }
- ], function(data) {
- t.equal(data[0], 1);
- t.equal(data[1], 2);
- t.equal(testsRun, 2);
- t.done();
- });
-};
-
-exports.multipleSeries = function(t) {
- t.expect(2);
- R.series([
- function(callback) {
- setTimeout(function() {
- callback(1);
- }, 200);
- }], function(data) {
- t.equal(data[0], 1);
- t.done();
- });
- R.series([
- function(callback) {
- setTimeout(function() {
- callback(2);
- }, 100);
- }], function(data) {
- t.equal(data[0], 2);
- });
-};
-
-exports.emptySeries = function(t) {
- t.expect(1);
- R.series([],
- function() {
- t.ok(true);
- t.done();
- });
-};
-
-exports.emptyParallel = function(t) {
- t.expect(1);
- R.parallel([],
- function() {
- t.ok(true);
- t.done();
- });
-};
-
-exports.testQueue = function(t) {
- var testsRun = 0;
-
- var q = R.queue(function(duration, callback) {
- setTimeout(function() {
- if (duration == 500) //test if 200 finished before it
- t.equal(testsRun, 1);
- testsRun++;
- callback(duration);
- }, duration);
- });
-
- q.push(500);
- q.push(200);
- q.run(function(data) {
- t.equal(testsRun, 2);
- t.equal(data[0], 500);
- t.equal(data[1], 200);
- t.done();
- });
-};
-
-exports.testQueueWithArray = function(t) {
- var testsRun = 0;
-
- var q = R.queue(function(duration, callback) {
- setTimeout(function() {
- if (duration == 500) //test if 200 finished before it
- t.equal(testsRun, 1);
- testsRun++;
- callback(duration);
- }, duration);
- });
-
- q.push([500, 200]);
- q.run(function(data) {
- t.equal(testsRun, 2);
- t.equal(data[0], 500);
- t.equal(data[1], 200);
- t.done();
- });
-};
-
-exports.testQueueSeries = function(t) {
- var testsRun = 0;
-
- var q = R.queue(function(duration, callback) {
- setTimeout(function() {
- if (duration == 500) //make sure running in series
- t.equal(testsRun, 0);
- testsRun++;
- callback(duration);
- }, duration);
- }, true);
-
- q.push(500);
- q.push(200);
- q.run(function(data) {
- t.equal(testsRun, 2);
- t.equal(data[0], 500);
- t.equal(data[1], 200);
- t.done();
- });
-};
-
-exports.testEmptyQueue = function(t) {
- var testsRun = 0;
-
- var q = R.queue(function(duration, callback) {
- setTimeout(function() {
- testsRun++;
- callback(duration);
- }, duration);
- });
- q.run(function(data) {
- t.equal(testsRun, 0);
- t.done();
- });
-};
-
-exports.testQueueClear = function(t) {
-
- var testsRun = 0;
-
- var q = R.queue(function(duration, callback) {
- setTimeout(function() {
- testsRun++;
- callback(duration);
- }, duration);
- }, true);
-
- q.push(500);
- q.push(200);
- q.clear();
- q.run(function(data) {
- t.equal(testsRun, 0);
- t.done();
- });
-};
-
-exports.testTwoQueues = function(t) {
-
- var testsRun = 0;
-
- var q = R.queue(function(duration, callback) {
- setTimeout(function() {
- testsRun++;
- callback(duration);
- }, duration);
- }, true);
-
- q.push(500);
- q.push(200);
- q.run(function(data) {
- t.equal(data[0], 500);
- t.equal(data[1], 200);
- });
-
- var q2 = R.queue(function(duration, callback) {
- setTimeout(function() {
- testsRun++;
- callback(duration);
- }, duration);
- }, true);
-
- q2.push(600);
- q2.push(300);
- q2.run(function(data) {
- t.equal(data[0], 600);
- t.equal(data[1], 300);
- t.done();
- });
-};
Oops, something went wrong.

0 comments on commit 10b79d3

Please sign in to comment.