UNPKG

@code-o-mat/globals

Version:

Abstract Package to support CodeOMat series of apps.

89 lines (71 loc) 1.95 kB
import Bunyan from 'bunyan'; const log = Bunyan.createLogger({name: "GlobalsTest"}); import 'mocha'; import { expect } from 'chai'; const codePath = process.env.NODE_ENV === "PRODUCTION" ? 'lib' : 'src'; const assertions = require(`../${codePath}/assertions/js-types`); const { assertIsArray, assertIsBoolean, assertIsFunction, assertIsNumber, assertIsObject, assertIsString, } = assertions; describe( `Test of the OMatGlobals JSType assertions`, ()=> { it('assert for Array', ()=> { const yes = new Array(); const no = true; const yesGo = () => assertIsArray(yes); const noGo = () => assertIsArray(no); expect(yesGo).to.not.throw(Error); expect(noGo).to.throw(Error); } ); it('assert for Boolean', ()=> { const yes = true; const no = "true"; const yesGo = () => assertIsArray(yes); const noGo = () => assertIsArray(no); expect(yesGo).to.throw(Error); expect(noGo).to.throw(Error); } ); it('assert for Function', ()=> { const yes = () => true; const no = true; const yesGo = () => assertIsArray(yes); const noGo = () => assertIsArray(no); expect(yesGo).to.throw(Error); expect(noGo).to.throw(Error); } ); it('assert for Array', ()=> { const yes = new Array(); const no = true; const yesGo = () => assertIsArray(yes); const noGo = () => assertIsArray(no); expect(yesGo).to.not.throw(Error); expect(noGo).to.throw(Error); } ); it('assert for Array', ()=> { const yes = new Array(); const no = true; const yesGo = () => assertIsArray(yes); const noGo = () => assertIsArray(no); expect(yesGo).to.not.throw(Error); expect(noGo).to.throw(Error); } ); } );