picomath/test/_picomath.js

16 lines
542 B
JavaScript

import assert from 'assert'
import math from '../picomath.js'
describe('The default full picomath instance "math"', () => {
it('performs basic arithmetic operations', () => {
assert.strictEqual(math.subtract(16, math.add(3,4,2)), 7)
assert.strictEqual(math.negate(math.number('8')), -8)
})
it('can be extended', () => {
math('add', [args => typeof args[0] === 'string',
(...addends) => addends.reduce((x,y) => x+y, '')])
assert.strictEqual(math.add('Kilroy',' is here'), 'Kilroy is here')
})
})