Last active
August 29, 2015 14:27
-
-
Save markotom/c0653be0f72c2aaa80c3 to your computer and use it in GitHub Desktop.
Mocha Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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