Permalink
Browse files

Added testing harness (nodeunit + sinon)

set_config tests as well
  • Loading branch information...
1 parent f4ec08f commit f1055f02ff3325cee4ea203256eaa8caffcd88ea @carlsverre carlsverre committed Sep 4, 2012
Showing with 51 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +15 −0 bin/run_tests
  4. +7 −0 package.json
  5. +25 −0 test/config.js
View
@@ -0,0 +1 @@
+node_modules
View
@@ -0,0 +1,3 @@
+[submodule "node_modules/nodeunit"]
+ path = node_modules/nodeunit
+ url = git://github.com/caolan/nodeunit.git
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+try {
+ var reporter = require('nodeunit').reporters.default;
+ var sinon = require('sinon');
+} catch(e) {
+ console.log("Testing dependencies not met.");
+ console.log("You can get them by running:");
+ console.log("");
+ console.log(" npm install");
+ console.log("");
+ process.exit();
+}
+
+process.chdir(__dirname + "/..");
+reporter.run(['test']);
View
@@ -15,5 +15,12 @@
},
"engines": {
"node": ">=0.4.0"
+ },
+ "scripts": {
+ "test": "bin/run_tests"
+ },
+ "devDependencies": {
+ "nodeunit": "0.7",
+ "sinon": "1.4"
}
}
View
@@ -0,0 +1,25 @@
+var Mixpanel = require('../lib/mixpanel-node');
+
+exports.config = {
+ setUp: function(cb) {
+ this.mixpanel = Mixpanel.init('asjdf');
+ cb();
+ },
+
+ "is set to correct defaults": function(test) {
+ test.deepEqual(this.mixpanel.config,
+ { test: false, debug: false },
+ "default config is correct");
+ test.done();
+ },
+
+ "is modified by set_config": function(test) {
+ test.equal(this.mixpanel.config.test, false, "default config has correct value for test");
+
+ this.mixpanel.set_config({ test: true });
+
+ test.equal(this.mixpanel.config.test, true, "set_config modifies the config");
+
+ test.done();
+ }
+};

0 comments on commit f1055f0

Please sign in to comment.