-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
const t = require('tap') | ||
const { log } = require('../') | ||
const { LEVELS } = log | ||
|
||
t.test('log', t => { | ||
t.matchSnapshot(LEVELS, 'log levels') | ||
t.test('all log.LEVELS have a function in log', t => { | ||
for (const level of LEVELS) { | ||
t.test(level, t => { | ||
t.match(log[level], Function) | ||
process.once('log', (actual, ...args) => { | ||
t.equal(actual, level, 'emitted log with expected level') | ||
t.same(args, [1, 'two', [3], { 4: 4 }], 'got expected args') | ||
t.end() | ||
const procLog = require('../') | ||
for (const method in procLog) { | ||
t.test(method, t => { | ||
const log = procLog[method] | ||
const { LEVELS } = log | ||
t.matchSnapshot(LEVELS, `${method} levels`) | ||
t.test(`all ${method}.LEVELS have a function in ${method}`, t => { | ||
for (const level of LEVELS) { | ||
t.test(level, t => { | ||
t.match(log[level], Function) | ||
process.once(method, (actual, ...args) => { | ||
t.equal(actual, level, `emitted ${method} with expected level`) | ||
t.same(args, [1, 'two', [3], { 4: 4 }], 'got expected args') | ||
t.end() | ||
}) | ||
log[level](1, 'two', [3], { 4: 4 }) | ||
}) | ||
log[level](1, 'two', [3], { 4: 4 }) | ||
}) | ||
} | ||
t.end() | ||
}) | ||
t.test('all log functions are in log.LEVELS', t => { | ||
t.plan(LEVELS.length) | ||
for (const fn in log) { | ||
if (fn !== 'LEVELS') { | ||
t.ok(LEVELS.includes(fn), `log.${fn} is in LEVELS`) | ||
} | ||
} | ||
t.end() | ||
}) | ||
t.test(`all ${method} functions are in ${method}.LEVELS`, t => { | ||
t.plan(LEVELS.length) | ||
for (const fn in log) { | ||
if (fn !== 'LEVELS') { | ||
t.ok(LEVELS.includes(fn), `${method}.${fn} is in ${method}.LEVELS`) | ||
} | ||
} | ||
}) | ||
t.end() | ||
}) | ||
t.end() | ||
}) | ||
} |