Created
December 16, 2017 09:25
-
-
Save alfasin/14de298c9fae0464df12d1553bf888a5 to your computer and use it in GitHub Desktop.
An example of how to use `tap` to create unit-tests
This file contains hidden or 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
var sum = function (a, b, f) { return f(null, a + b) } | |
var test = require('tap').test; | |
test('sums 1 and 2', function (t) { | |
sum(1, 2, function (err, result) { | |
t.notOk(err, 'no error'); | |
t.equal(result, 3, '1 + 2 should be equal to 3'); | |
t.end(); | |
}); | |
}); | |
test('sums 5 and 0', function (t) { | |
sum(5, 0, function(err, result) { | |
t.notOk(err, 'no error'); | |
t.equal(result, 5, '5 + 0 should be equal to 3'); | |
t.end(); | |
}); | |
}); | |
test('sums 5 and -2', function (t) { | |
sum(5, -2, function (err, result) { | |
t.notOk(err, 'no error'); | |
t.equal(result, 3, '5 + -2 should be equal to 3'); | |
t.end(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment