Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Dec 26, 2024
1 parent 1a2ea91 commit b5cbb95
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
coverageReporters: ['text', 'lcov', 'json-summary'],
coverageDirectory: 'coverage',
collectCoverageFrom: ['scripts/**/*.js'],
coveragePathIgnorePatterns: ['scripts/compose.js'],
coveragePathIgnorePatterns: ['scripts/compose.js', 'scripts/tools/categorylist.js', 'scripts/tools/tags-color.js'],
// To disallow netlify edge function tests from running
testMatch: ['**/tests/**/*.test.*', '!**/netlify/**/*.test.*'],
};
1 change: 1 addition & 0 deletions scripts/build-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const TARGET_DIR = 'pages';
const capitalizeTags = ['table', 'tr', 'td', 'th', 'thead', 'tbody'];

// Check if target directory doesn't exist then create it
/* istanbul ignore next */
if (!fs.existsSync(TARGET_DIR)) {
fs.mkdirSync(TARGET_DIR, { recursive: true });
}
Expand Down
5 changes: 5 additions & 0 deletions tests/dashboard/build-dashboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,9 @@ describe('GitHub Discussions Processing', () => {
localConsoleErrorSpy.mockRestore();
});

it('should handle write failures gracefully', async () => {

await expect(writeToFile).rejects.toThrow();
});

});
11 changes: 11 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const buildCaseStudiesList = require('../scripts/casestudies');
const buildAdoptersList = require('../scripts/adopters');
const buildFinanceInfoList = require('../scripts/finance');
const start = require('../scripts/index');
const fs = require('fs')

jest.mock('../scripts/build-rss');
jest.mock('../scripts/build-post-list');
Expand Down Expand Up @@ -32,4 +33,14 @@ describe('start function', () => {
expect(buildAdoptersList).toHaveBeenCalled();
expect(buildFinanceInfoList).toHaveBeenCalled();
});

test('should throw an error if no finance data is found', async () => {
jest.spyOn(fs, 'readdirSync').mockReturnValue([]);

await expect(start()).rejects.toThrow('No finance data found in the finance directory.');

expect(buildFinanceInfoList).not.toHaveBeenCalled();

fs.readdirSync.mockRestore();
});
});

0 comments on commit b5cbb95

Please sign in to comment.