Skip to content

Commit

Permalink
fixed test cases for config, title, vis
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Jun 12, 2024
1 parent fd8ac2f commit c0d4ad3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 314 deletions.
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ module.exports = {
moduleNameMapper: {
'\\.css$': 'identity-obj-proxy',
},
setupFilesAfterEnv: ['@testing-library/jest-dom'],
setupFilesAfterEnv: ['./tests/setupTests.js'],
transformIgnorePatterns: [
'/node_modules/(?!react-dnd)/', // Ignore node_modules except for react-dnd
],
setupFilesAfterEnv: ['@testing-library/jest-dom', './tests/setupTests.js'],
};

2 changes: 1 addition & 1 deletion source/components/Layout/VisGridView/VisGridView.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
width: 0,
currentCols: 0,
layout: [],
margin: 0,
margins: [], // Initialize margins as an empty array or with default values
grid,
});
const self = useRef();
Expand Down
18 changes: 13 additions & 5 deletions tests/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ import testData from '../config/wines_data.json';



describe('App', () => {
test('renders more than 0 visible items with react-grid-item class', async () => {
describe('Eaglescope basic tests', () => {
test('renders title from config', async () => {
const container = render(
<App overrideConfig={testConfig} overrideData={testData}/>
);
await waitFor(() => {
const titleElement = screen.getByText('Eaglescope Demo | Wines');
expect(titleElement).toBeInTheDocument();
});
});
test('renders vis elems', async () => {
const container = render(
<App overrideConfig={testConfig} overrideData={testData}/>
);

await waitFor(() => {
const items = container.getAllByClassName('react-grid-item');
expect(items.length).toBeGreaterThan(0);
const elements = document.getElementsByClassName('vis-grid-item');
expect(elements.length).toBeGreaterThan(6);
});
});
});
9 changes: 9 additions & 0 deletions tests/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const fetch = require('cross-fetch');

global.fetch = fetch;


window.matchMedia = jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated, but still used in some cases
removeListener: jest.fn(), // Deprecated, but still used in some cases
}));
Loading

0 comments on commit c0d4ad3

Please sign in to comment.