Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .visible for emitting text only when enabled (fixes #192)
- Loading branch information
1 parent
4372d27
commit dc092b4
Showing
5 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import test from 'ava'; | ||
|
||
// Spoof supports-color | ||
require('./_supports-color')(__dirname); | ||
|
||
const m = require('..'); | ||
|
||
test('visible: normal output when enabled', t => { | ||
const ctx = new m.constructor({level: 3, enabled: true}); | ||
t.is(ctx.visible.red('foo'), '\u001B[31mfoo\u001B[39m'); | ||
t.is(ctx.red.visible('foo'), '\u001B[31mfoo\u001B[39m'); | ||
}); | ||
|
||
test('visible: no output when disabled', t => { | ||
const ctx = new m.constructor({level: 3, enabled: false}); | ||
t.is(ctx.red.visible('foo'), ''); | ||
t.is(ctx.visible.red('foo'), ''); | ||
}); | ||
|
||
test('visible: no output when level is too low', t => { | ||
const ctx = new m.constructor({level: 0, enabled: true}); | ||
t.is(ctx.visible.red('foo'), ''); | ||
t.is(ctx.red.visible('foo'), ''); | ||
}); |
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