Skip to content

Instantly share code, notes, and snippets.

@markotom
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markotom/c0653be0f72c2aaa80c3 to your computer and use it in GitHub Desktop.
Save markotom/c0653be0f72c2aaa80c3 to your computer and use it in GitHub Desktop.
Mocha Example
'use strict';
var assert = require('assert');
var EqModule = function () {};
EqModule.prototype.solve = function (a) {
var val = 0;
a.forEach(function (n) {
val += n;
});
return val;
};
var eqModule = new EqModule();
// Defining a suite of tests
describe('EQ Module', function () {
it('should be a function', function () {
assert.equal(typeof EqModule, 'function'); // should returns true
});
it('should be an instance of EqModule', function () {
assert.equal(eqModule instanceof EqModule, true); // should returns true
});
it('should return the correct value', function () {
var val = eqModule.solve([1,2,3]);
assert.equal(val, 6); // should returns 6
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment