Skip to content

Commit

Permalink
test(loggerImpl): write tests for loggerImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Koenders committed Sep 11, 2018
1 parent 784a1db commit 97ee041
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/unit/libraries/logger/loggerImplSpec.ts
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');
});
});

0 comments on commit 97ee041

Please sign in to comment.