Skip to content

Instantly share code, notes, and snippets.

@timsavery
Created July 2, 2012 21:11
Show Gist options
  • Save timsavery/3035716 to your computer and use it in GitHub Desktop.
Save timsavery/3035716 to your computer and use it in GitHub Desktop.
==============================================================
MODULE :: hello.js
==============================================================
module.exports = function hello(name) {
this.name = name;
this.sayIt = function() {
return "Hello " + this.name;
};
};
==============================================================
TEST CASE :: test/hello-test.js
==============================================================
var testcase = require('nodeunit').testCase;
exports.plain = testcase({
testSayIt: function(test) {
test.expect(1);
var hello = require('./hello')
, testHello = new hello('Wil');
test.equal('Hello Wil', testHello.sayIt());
test.done();
}
});
==============================================================
RUN TEST
==============================================================
~$ nodeunit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment