Skip to content

Instantly share code, notes, and snippets.

@zxqx
Last active April 8, 2016 21:44
Show Gist options
  • Save zxqx/732b7290309894aec313 to your computer and use it in GitHub Desktop.
Save zxqx/732b7290309894aec313 to your computer and use it in GitHub Desktop.
unit-test.js
// ------------------------------------------
// square-number.js
// ------------------------------------------
module.exports = squareNumber;
function squareNumber(number)
{
return number * number;
}
// ------------------------------------------
// test.js
// ------------------------------------------
const test = require('tape');
const squareNumber = require('../square-number.js');
test('squares numbers', function(t) {
t.plan(3);
t.equals(squareNumber(5), 25);
t.equals(squareNumber(12), 144);
t.equals(squareNumber(0), 0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment