Skip to content

Commit 42afa86

Browse files
committed
chapter 03: fixing logAnalyzer tests, that right now are some of them are integration tests and not unit tests, meh
1 parent 95768cf commit 42afa86

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ describe.each([
1010
['johndoe.slf', true],
1111
['johndoe.SLF', true],
1212
])('isValidLogFileName("%s"))', (fileName, expected) => {
13-
it(`bad extension returns ${expected}`, () => {
14-
const result = logAnalyzerInstance.isValidLogFileName(fileName);
13+
it(`bad extension returns ${expected}`, async () => {
14+
const result = await logAnalyzerInstance.isValidLogFileName(fileName);
1515
expect(result).toBe(expected);
1616
});
1717
});
1818

1919
describe('isValidLogFileName', () => {
20-
it('empty filename throws error', () => {
21-
function emptyLogFileName() {
22-
logAnalyzerInstance.isValidLogFileName('');
20+
it('empty filename throws error', async () => {
21+
async function emptyLogFileName() {
22+
return logAnalyzerInstance.isValidLogFileName('');
2323
}
2424

25-
expect(emptyLogFileName).toThrow('filename has to be provided');
25+
await expect(emptyLogFileName()).rejects.toThrow(
26+
'filename has to be provided'
27+
);
2628
});
2729

2830
/**
@@ -34,9 +36,8 @@ describe('isValidLogFileName', () => {
3436
${'johndoe.slf'} | ${true}
3537
`(
3638
'when called there changes wasLastFileNameValid that returns $expected',
37-
({ fileName, expected }) => {
38-
console.log(fileName);
39-
logAnalyzerInstance.isValidLogFileName(fileName);
39+
async ({ fileName, expected }) => {
40+
await logAnalyzerInstance.isValidLogFileName(fileName);
4041
const result = logAnalyzerInstance.getWasLastFileNameValid();
4142

4243
expect(result).toBe(expected);

0 commit comments

Comments
 (0)