Home Reference Source Test

test/common/utils.spec.js

  1. import { expect } from 'chai'
  2.  
  3. import { pad, isNull, isUndefined } from '../../src/common/utils'
  4.  
  5. /** @test {pad} */
  6. describe('pad', () => {
  7. it('returns the next multiple of 4', () => {
  8. expect(pad(2)).to.be.equals(4)
  9. expect(pad(8)).to.be.equals(8)
  10. expect(pad(31)).to.be.equals(32)
  11. expect(pad(0)).to.be.equals(0)
  12. })
  13. })
  14.  
  15. /** @test {isNull} */
  16. describe('isNull', () => {
  17. it('correctly identifies null value', () => {
  18. expect(isNull(0)).to.be.false
  19. expect(isNull(undefined)).to.be.false
  20. expect(isNull(null)).to.be.true
  21. })
  22. })
  23.  
  24. /** @test {isUndefined} */
  25. describe('isUndefined', () => {
  26. it('correctly identifies undefined value', () => {
  27. expect(isUndefined(0)).to.be.false
  28. expect(isUndefined(undefined)).to.be.true
  29. expect(isUndefined(null)).to.be.false
  30. })
  31. })