feathers/packages/commons/test/debug.test.ts
David Luecke c606c56dc2
chore: Format code using Prettier and updated ESLint rules (#2647)
Co-authored-by: Marshall Thompson <marshall@creativeideal.net>
2022-05-27 15:21:13 -07:00

33 lines
784 B
TypeScript

import { strict as assert } from 'assert'
import { createDebug, setDebug, noopDebug } from '../src'
const myDebug = createDebug('hello test')
describe('debug', () => {
it('default debug does nothing', () => {
assert.equal(myDebug('hi', 'there'), undefined)
})
it('can set custom debug later', () => {
let call
const customDebug =
(name: string) =>
(...args: any[]) => {
call = [name].concat(args)
}
setDebug(customDebug)
assert.equal(myDebug('hi', 'there'), undefined)
assert.deepEqual(call, ['hello test', 'hi', 'there'])
const newDebug = createDebug('other test')
assert.equal(newDebug('other', 'there'), undefined)
assert.deepEqual(call, ['other test', 'other', 'there'])
setDebug(noopDebug)
})
})