Skip to content

Commit 7e50568

Browse files
committed
chapter 02: add test that assert that the error is thrown
1 parent 279aacc commit 7e50568

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
const logAnalyzer = require('./logAnalyzer');
22

3+
let logAnalyzerInstance;
4+
beforeEach(() => {
5+
logAnalyzerInstance = logAnalyzer();
6+
});
7+
38
describe.each([
49
['johndoe.js', false],
510
['johndoe.slf', true],
611
['johndoe.SLF', true],
712
])('isValidLogFileName("%s"))', (fileName, expected) => {
8-
let logAnalyzerInstance;
9-
beforeEach(() => {
10-
logAnalyzerInstance = logAnalyzer();
11-
});
12-
1313
it(`bad extension returns ${expected}`, () => {
1414
const result = logAnalyzerInstance.isValidLogFileName(fileName);
1515
expect(result).toBe(expected);
1616
});
1717
});
18+
19+
describe('isValidLogFileName', () => {
20+
it('empty filename throws error', () => {
21+
function emptyLogFileName() {
22+
logAnalyzerInstance.isValidLogFileName('');
23+
}
24+
25+
expect(emptyLogFileName).toThrow('filename has to be provided');
26+
});
27+
});

0 commit comments

Comments
 (0)