definitions approximately(actual, expected, delta, [message])
@param { Number } actual
@param { Number } expected
@param { Number } delta
@param { String } message
suite(‘Function convertHandler.convert(num, unit)’, function() {
test('Gal to L', function(done) {
var input = [5, 'gal'];
var expected = 18.9271;
console.log(!isNaN((convertHandler.convert(input[0],input[1]))))// get true
assert.approximately(convertHandler.convert(input[0],input[1]),expected,0.1); //0.1 tolerance
done();
});
Function convertHandler.convert(num, unit)
12:54 PM
true
1) Gal to L
-
Unit Tests
Function convertHandler.convert(num, unit)
Gal to L:
AssertionError: expected ‘18.92705’ to be a number
at Context. (tests/1_unit-tests.js:112:14)
I solved by formatting Number()