create-debugger.spec.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import {expect} from '../chai.js';
  2. import {format} from '@e22m4u/js-format';
  3. import {createDebugger} from './create-debugger.js';
  4. describe('createDebugger', function () {
  5. it('requires the first parameter to be a String', function () {
  6. const throwable = v => () => createDebugger(v);
  7. const error = v =>
  8. format(
  9. 'The first argument of "createDebugger" should be ' +
  10. 'a String, but %s given.',
  11. v,
  12. );
  13. expect(throwable(10)).to.throw(error('10'));
  14. expect(throwable(0)).to.throw(error('0'));
  15. expect(throwable(true)).to.throw(error('true'));
  16. expect(throwable(false)).to.throw(error('false'));
  17. expect(throwable(null)).to.throw(error('null'));
  18. expect(throwable({})).to.throw(error('Object'));
  19. expect(throwable([])).to.throw(error('Array'));
  20. expect(throwable(undefined)).to.throw(error('undefined'));
  21. throwable('str')();
  22. throwable('')();
  23. });
  24. it('returns a function', function () {
  25. const res = createDebugger('name');
  26. expect(typeof res).to.be.eq('function');
  27. });
  28. });