-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
c725589
commit fd8194a
Showing
8 changed files
with
92 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import test from 'tape'; | ||
import { MockConsole } from '@vanillaes/mock-console'; | ||
import test from 'tape' | ||
import { MockConsole } from '@vanillaes/mock-console' | ||
|
||
test('MockConsole.capture() - Should should capture logs', (t) => { | ||
const mc = new MockConsole(); | ||
mc.capture(); | ||
const log = 'console.log captured'; | ||
const info = 'console.info captured'; | ||
const error = 'console.error captured'; | ||
console.log(log); | ||
console.info(info); | ||
console.error(error); | ||
mc.restore(); | ||
const mc = new MockConsole() | ||
mc.capture() | ||
const log = 'console.log captured' | ||
const info = 'console.info captured' | ||
const error = 'console.error captured' | ||
console.log(log) | ||
console.info(info) | ||
console.error(error) | ||
mc.restore() | ||
|
||
t.deepEqual(mc.logs, [log], 'console.log() should be captured'); | ||
t.deepEqual(mc.infos, [info], 'console.info() should be captured'); | ||
t.deepEqual(mc.errors, [error], 'console.error() should be captured'); | ||
t.deepEqual(mc.logs, [log], 'console.log() should be captured') | ||
t.deepEqual(mc.infos, [info], 'console.info() should be captured') | ||
t.deepEqual(mc.errors, [error], 'console.error() should be captured') | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |
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,16 +1,16 @@ | ||
const test = require('tape'); | ||
const { MockConsole } = require('@vanillaes/mock-console'); | ||
const test = require('tape') | ||
const { MockConsole } = require('@vanillaes/mock-console') | ||
|
||
test('Compat - Ensure the package works with CommonJS', (t) => { | ||
const mc = new MockConsole(); | ||
const mc = new MockConsole() | ||
|
||
t.notEqual(mc, null, 'MockConsole should exist'); | ||
t.equal(mc.log, console.log, 'MockConsole.log should store a reference to console.log'); | ||
t.equal(mc.info, console.info, 'MockConsole.info should store a reference to console.info'); | ||
t.equal(mc.error, console.error, 'MockConsole.error should store a reference to console.error'); | ||
t.deepEqual(mc.logs, [], 'MockConsole.logs should contain an empty array'); | ||
t.deepEqual(mc.infos, [], 'MockConsole.infos should contain an empty array'); | ||
t.deepEqual(mc.errors, [], 'MockConsole.errors should contain an empty array'); | ||
t.notEqual(mc, null, 'MockConsole should exist') | ||
t.equal(mc.log, console.log, 'MockConsole.log should store a reference to console.log') | ||
t.equal(mc.info, console.info, 'MockConsole.info should store a reference to console.info') | ||
t.equal(mc.error, console.error, 'MockConsole.error should store a reference to console.error') | ||
t.deepEqual(mc.logs, [], 'MockConsole.logs should contain an empty array') | ||
t.deepEqual(mc.infos, [], 'MockConsole.infos should contain an empty array') | ||
t.deepEqual(mc.errors, [], 'MockConsole.errors should contain an empty array') | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |
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,14 +1,14 @@ | ||
import test from 'tape'; | ||
import { MockConsole } from '@vanillaes/mock-console'; | ||
import test from 'tape' | ||
import { MockConsole } from '@vanillaes/mock-console' | ||
|
||
test('MockConsole.disable() - Should disable logging', (t) => { | ||
const mc = new MockConsole(); | ||
mc.disable(); | ||
const mc = new MockConsole() | ||
mc.disable() | ||
|
||
t.notEqual(mc.log, console.log, 'console.log() should be disabled'); | ||
t.notEqual(mc.info, console.info, 'console.info() should be disabled'); | ||
t.notEqual(mc.error, console.error, 'console.error() should be disabled'); | ||
t.notEqual(mc.log, console.log, 'console.log() should be disabled') | ||
t.notEqual(mc.info, console.info, 'console.info() should be disabled') | ||
t.notEqual(mc.error, console.error, 'console.error() should be disabled') | ||
|
||
mc.restore(); | ||
t.end(); | ||
}); | ||
mc.restore() | ||
t.end() | ||
}) |
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,18 +1,18 @@ | ||
import test from 'tape'; | ||
import { MockConsole } from '@vanillaes/mock-console'; | ||
import test from 'tape' | ||
import { MockConsole } from '@vanillaes/mock-console' | ||
|
||
test('MockConsole.flush() - Should flushes all log buffers', (t) => { | ||
const mc = new MockConsole(); | ||
mc.capture(); | ||
console.log('console.log captured'); | ||
console.info('console.info captured'); | ||
console.error('console.error captured'); | ||
mc.flush(); | ||
mc.restore(); | ||
const mc = new MockConsole() | ||
mc.capture() | ||
console.log('console.log captured') | ||
console.info('console.info captured') | ||
console.error('console.error captured') | ||
mc.flush() | ||
mc.restore() | ||
|
||
t.deepEqual(mc.logs, [], 'console.logs should be empty'); | ||
t.deepEqual(mc.infos, [], 'console.infos should be empty'); | ||
t.deepEqual(mc.errors, [], 'console.errors should be empty'); | ||
t.deepEqual(mc.logs, [], 'console.logs should be empty') | ||
t.deepEqual(mc.infos, [], 'console.infos should be empty') | ||
t.deepEqual(mc.errors, [], 'console.errors should be empty') | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |
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,14 +1,14 @@ | ||
import test from 'tape'; | ||
import { MockConsole } from '@vanillaes/mock-console'; | ||
import test from 'tape' | ||
import { MockConsole } from '@vanillaes/mock-console' | ||
|
||
test('MockConsole.restore() - Should restore built-in logging', (t) => { | ||
const mc = new MockConsole(); | ||
mc.disable(); | ||
mc.restore(); | ||
const mc = new MockConsole() | ||
mc.disable() | ||
mc.restore() | ||
|
||
t.equal(mc.log, console.log, 'console.log() should be restored'); | ||
t.equal(mc.info, console.info, 'console.info() should be restored'); | ||
t.equal(mc.error, console.error, 'console.error() should be restored'); | ||
t.equal(mc.log, console.log, 'console.log() should be restored') | ||
t.equal(mc.info, console.info, 'console.info() should be restored') | ||
t.equal(mc.error, console.error, 'console.error() should be restored') | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |
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,11 +1,11 @@ | ||
import test from 'tape'; | ||
import { MockConsole } from '@vanillaes/mock-console'; | ||
import test from 'tape' | ||
import { MockConsole } from '@vanillaes/mock-console' | ||
|
||
test('Singleton - MockConsole should be a singleton', (t) => { | ||
const mc = new MockConsole(); | ||
const mc2 = new MockConsole(); | ||
const mc = new MockConsole() | ||
const mc2 = new MockConsole() | ||
|
||
t.equal(mc, mc2, 'MockConsoles should all point to the same instance'); | ||
t.equal(mc, mc2, 'MockConsoles should all point to the same instance') | ||
|
||
t.end(); | ||
}); | ||
t.end() | ||
}) |