Skip to content

Commit

Permalink
chapter 07: refactored solution based in abstract test infrastructure…
Browse files Browse the repository at this point in the history
… class pattern
  • Loading branch information
devcorpio committed Jan 13, 2019
1 parent 2fc73fd commit df26d6d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const configurationManagerFactory = require('./configurationManager');
const loggingFacility = require('./loggingFacility');
const { fakeTheLogger, tearDown } = require('./testsUtils/baseTests');

describe('isConfigured', () => {
it('logging file check', () => {
fakeTheLogger();
const configurationManager = configurationManagerFactory();
configurationManager.isConfigured('');
});

afterEach(() => {
loggingFacility.setLogger(null);
});
afterEach(tearDown);
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const logAnalyzerFactory = require('./logAnalyzer');
const loggingFacility = require('./loggingFacility');
const { fakeTheLogger, tearDown } = require('./testsUtils/baseTests');

describe('analyze', () => {
it('empty file throws exception', () => {
fakeTheLogger();
const logAnalyzer = logAnalyzerFactory();
logAnalyzer.analyze('');
});

afterEach(() => {
loggingFacility.setLogger(null);
});
afterEach(tearDown);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let loggingFacility = require('../loggingFacility');

function fakeTheLogger() {
loggingFacility.setLogger(function fakeLogger(value) {
return value;
});
}

function tearDown() {
loggingFacility.setLogger(null);
}

module.exports = {
fakeTheLogger,
tearDown,
};

0 comments on commit df26d6d

Please sign in to comment.