Skip to content

Commit ceb8d02

Browse files
committed
chapter 03: using extensionManagerFactory I created an integration test, because the test is making use of a external dependency, the filesystem
1 parent 3ea220e commit ceb8d02

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

chapter_03-using-stubs-to-break-dependencies/LogAn/logAnalyzer.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const logAnalyzerFactory = require('./logAnalyzer');
22
const fakeExtensionManagerFactory = require('./fakeExtensionManager');
3+
const extensionManagerFactory = require('./extensionManager');
34

45
let myFakeExtensionManager;
56

@@ -53,4 +54,17 @@ describe('isValidLogFileName', () => {
5354
expect(result).toBe(expected);
5455
}
5556
);
57+
58+
/**
59+
* an example of use of "injecting a fake just before a method call"
60+
* right now I'm not injecting a fake, and extensionManager is returning fileExtensionManager,
61+
* therefore this test is an integration test and not a unit test!!!!
62+
*/
63+
it('return true using extensionManagerFactory', async () => {
64+
const extensionManager = extensionManagerFactory();
65+
const logAnalyzer = logAnalyzerFactory(extensionManager.create());
66+
const result = await logAnalyzer.isValidLogFileName('johndoe.sql');
67+
68+
expect(result).toBe(true);
69+
});
5670
});

0 commit comments

Comments
 (0)