Skip to content

Commit 2a2cb75

Browse files
committed
Mock Circos component in tests
A recent change has made it so that Circos graphs are rendered by default. This has syrfaced an issue that d3 is not set up in the test suite with jsdom properly and was erring. The tests do not require Circos graphs to render, so we can mock the component fully. R
1 parent daca86c commit 2a2cb75

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module.exports = {
4141
'download_links': '<rootDir>/public/js/null_plugins/download_links.js',
4242
'hit_buttons': '<rootDir>/public/js/null_plugins/hit_buttons.js',
4343
'search_header_plugin': '<rootDir>/public/js/null_plugins/search_header_plugin.js',
44+
'circos$': '<rootDir>/public/js/tests/mocks/circos.js',
4445
},
4546
watchPlugins: [
4647
'jest-watch-typeahead/filename',

public/js/tests/mocks/circos.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const Circos = () => {
2+
// console.log("Circos mock loaded");
3+
return <div></div>;
4+
};
5+
6+
export default Circos;

public/js/tests/report.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Report from '../report';
55
import Sidebar from '../sidebar';
66
import shortResponseJSON from './mock_data/short_response.json';
77
import longResponseJSON from './mock_data/long_response.json';
8-
import d3 from 'd3';
98

109
const setMockJSONResult = (result) => {
1110
global.$.getJSON = () => ({ complete: jest.fn((callback) => callback(result)) });
@@ -45,6 +44,7 @@ describe('REPORT PAGE', () => {
4544
render(<Report showErrorModal={showErrorModal} />);
4645
expect(showErrorModal).toHaveBeenCalledTimes(1);
4746
});
47+
4848
it('it should render the report page correctly if there\'s a response provided', () => {
4949
setMockJSONResult({ status: 200, responseJSON: shortResponseJSON });
5050
const { container } = render(<Report getCharacterWidth={jest.fn()} />);

0 commit comments

Comments
 (0)