-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(loggerImpl): write tests for loggerImpl
- Loading branch information
Sander Koenders
committed
Sep 11, 2018
1 parent
784a1db
commit 97ee041
Showing
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as sinon from 'sinon'; | ||
import { assert } from 'chai'; | ||
import LoggerImpl from '../../../../src/libraries/logger/loggerImpl'; | ||
|
||
const fakeConsole = { | ||
log: sinon.stub() | ||
}; | ||
|
||
describe('LoggerImpl', () => { | ||
const appName = 'InversifyJsExample'; | ||
const sandbox = sinon.createSandbox(); | ||
|
||
let subjectUnderTest: LoggerImpl; | ||
|
||
beforeEach(() => { | ||
subjectUnderTest = new LoggerImpl({ appName }, fakeConsole); | ||
}); | ||
|
||
afterEach(() => sandbox.restore()); | ||
|
||
it('should call "console.log" when log is called', () => { | ||
const message = 'test'; | ||
|
||
subjectUnderTest.log(message); | ||
|
||
const consoleLogCalled = fakeConsole.log.calledWith(appName + ' says: ' + message); | ||
assert(consoleLogCalled, 'console.log should have been called'); | ||
}); | ||
}); |