Skip to content

Commit 7bffabc

Browse files
committed
Added one more test
Added coverage report in html
1 parent c65a1ab commit 7bffabc

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

jest.config.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
module.exports = {
33
preset: 'ts-jest',
44
testEnvironment: 'node',
5-
collectCoverageFrom: [
6-
'src/**/*.ts',
5+
collectCoverage: true,
6+
verbose: true,
7+
coverageDirectory: 'coverage',
8+
moduleFileExtensions: ["ts", "js", "json"],
9+
testMatch: [
10+
"<rootDir>/test/**/*.ts?(x)",
11+
"<rootDir>/src/**/?(*.)+(spec|test).ts?(x)"
12+
],
13+
coverageReporters: [
14+
"json",
15+
"html",
16+
"text"
717
],
818
};

test/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('MarkdownIndexGenerator', () => {
1212
it('should show the generated menu', async () => {
1313
await MarkdownIndexGenerator('./test/__mocks__/test.md');
1414
expect(console.log).toHaveBeenCalledWith('--- Begin MarkDown ---');
15+
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Index'));
1516
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('[Heading 2](#heading-2)'));
1617
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('- [Sub sub heading 4](#sub-sub-heading-4)'));
1718
expect(console.log).toHaveBeenCalledWith('--- End Markdown ---');
@@ -24,4 +25,13 @@ describe('MarkdownIndexGenerator', () => {
2425
expect(console.log).toHaveBeenCalledWith(expect.not.stringContaining('- [Sub sub heading 4](#sub-sub-heading-4)'));
2526
expect(console.log).toHaveBeenCalledWith('--- End Markdown ---');
2627
});
28+
29+
it('should show the generated menu, and contain a custom title', async () => {
30+
await MarkdownIndexGenerator('./test/__mocks__/test.md', { title: 'test', depth: 2, replace: false });
31+
expect(console.log).toHaveBeenCalledWith('--- Begin MarkDown ---');
32+
expect(console.log).toHaveBeenCalledWith(expect.not.stringContaining('Index'));
33+
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('[Heading 2](#heading-2)'));
34+
expect(console.log).toHaveBeenCalledWith(expect.not.stringContaining('- [Sub sub heading 4](#sub-sub-heading-4)'));
35+
expect(console.log).toHaveBeenCalledWith('--- End Markdown ---');
36+
});
2737
});

0 commit comments

Comments
 (0)