Added unit tests for "parser.js" and "util.js"

This commit is contained in:
euvl
2017-08-07 16:07:57 +01:00
parent 72f5222e4b
commit 0089717a8c
10 changed files with 186 additions and 7 deletions

26
test/unit/util.spec.js Normal file
View File

@@ -0,0 +1,26 @@
var util = require('../../src/util')
var { expect } = require('chai')
describe('util.js', () => {
describe('#inRange', () => {
it('Should return the source value (in the range)', () => {
let value = util.inRange(-10, 10, 0)
expect(value).to.equal(0)
})
it('Should not be equal to the source value (outside the range)', () => {
let value = util.inRange(-10, 10, -100)
expect(value).not.to.equal(-100)
})
it('Should replace source value with upper limit', () => {
let value = util.inRange(0, 10, 30)
expect(value).to.equal(10)
})
it('Should replace source value with lower limit', () => {
let value = util.inRange(1, 10, -1)
expect(value).to.equal(1)
})
})
})