Skip to content

Commit

Permalink
chapter 03: using extensionManagerFactory I created an integration te…
Browse files Browse the repository at this point in the history
…st, because the test is making use of a external dependency, the filesystem
  • Loading branch information
devcorpio committed Jan 11, 2019
1 parent 3ea220e commit ceb8d02
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const logAnalyzerFactory = require('./logAnalyzer');
const fakeExtensionManagerFactory = require('./fakeExtensionManager');
const extensionManagerFactory = require('./extensionManager');

let myFakeExtensionManager;

Expand Down Expand Up @@ -53,4 +54,17 @@ describe('isValidLogFileName', () => {
expect(result).toBe(expected);
}
);

/**
* an example of use of "injecting a fake just before a method call"
* right now I'm not injecting a fake, and extensionManager is returning fileExtensionManager,
* therefore this test is an integration test and not a unit test!!!!
*/
it('return true using extensionManagerFactory', async () => {
const extensionManager = extensionManagerFactory();
const logAnalyzer = logAnalyzerFactory(extensionManager.create());
const result = await logAnalyzer.isValidLogFileName('johndoe.sql');

expect(result).toBe(true);
});
});

0 comments on commit ceb8d02

Please sign in to comment.