Skip to content

Commit

Permalink
DSEGOG-341 Update filtering, images, preloader and table tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Aug 13, 2024
1 parent d8de31b commit f295281
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/__snapshots__/settingsMenuItems.component.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Settings Menu Items component renders dropdown only when menu is visible 1`] = `
exports[`Settings Menu Items component > renders dropdown only when menu is visible 1`] = `
<body>
<div />
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`False colour panel component renders correctly 1`] = `
exports[`False colour panel component > renders correctly 1`] = `
<DocumentFragment>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 css-1ps6pg7-MuiPaper-root"
Expand Down
4 changes: 2 additions & 2 deletions src/images/__snapshots__/imageView.component.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Image view component renders an image and a canvas overlay 1`] = `
exports[`Image view component > renders an image and a canvas overlay 1`] = `
<DocumentFragment>
<div
style="position: relative;"
Expand Down
28 changes: 16 additions & 12 deletions src/images/imageWindow.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ import { TraceOrImageWindow } from '../state/slices/windowSlice';
import { renderComponentWithProviders } from '../testUtils';
import ImageWindow from './imageWindow.component';

jest.mock('../windows/windowPortal.component', () => {
vi.mock('../windows/windowPortal.component', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ReactMock = require('react');
return ReactMock.forwardRef(({ children }, ref) => (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<mock-WindowPortal>{children}</mock-WindowPortal>
));
return {
default: ReactMock.forwardRef(({ children }, ref) => (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<mock-WindowPortal>{children}</mock-WindowPortal>
)),
};
});

jest.mock('./imageView.component', () => () => (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<mock-ImageView data-testid="mock-image-view" />
));
vi.mock('./imageView.component', () => ({
default: () => (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<mock-ImageView data-testid="mock-image-view" />
),
}));

describe('Image Window component', () => {
let testImageConfig: TraceOrImageWindow;
Expand Down Expand Up @@ -55,7 +59,7 @@ describe('Image Window component', () => {
});

it('renders correctly while image is loading', () => {
const loadingHandler = (req, res, ctx) => {
const loadingHandler = () => {
// taken from https://github.com/mswjs/msw/issues/778 - a way of mocking pending promises without breaking jest
return new Promise(() => undefined);
};
Expand Down
6 changes: 3 additions & 3 deletions src/preloader/__snapshots__/preloader.component.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Preloader component does not render when the site is not loading 1`] = `
exports[`Preloader component > does not render when the site is not loading 1`] = `
<DocumentFragment>
<div>
<div>
Expand All @@ -10,7 +10,7 @@ exports[`Preloader component does not render when the site is not loading 1`] =
</DocumentFragment>
`;

exports[`Preloader component renders when the site is loading 1`] = `
exports[`Preloader component > renders when the site is loading 1`] = `
<DocumentFragment>
<div>
<div
Expand Down
6 changes: 3 additions & 3 deletions src/table/__snapshots__/table.component.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Table renders correctly with all columns displayed 1`] = `
exports[`Table > renders correctly with all columns displayed 1`] = `
<DocumentFragment>
<div>
<div
Expand Down Expand Up @@ -905,7 +905,7 @@ exports[`Table renders correctly with all columns displayed 1`] = `
</DocumentFragment>
`;

exports[`Table renders correctly, with only timestamp column 1`] = `
exports[`Table > renders correctly, with only timestamp column 1`] = `
<DocumentFragment>
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Data Cell renders correctly 1`] = `
exports[`Data Cell > renders correctly 1`] = `
<DocumentFragment>
<table>
<tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Data Header opens menu when menu icon is clicked 1`] = `
exports[`Data Header > opens menu when menu icon is clicked 1`] = `
<ul
aria-labelledby="test-menu-button"
class="MuiList-root MuiList-padding MuiList-dense MuiMenu-list css-6hp17o-MuiList-root-MuiMenu-list"
Expand Down Expand Up @@ -77,7 +77,7 @@ exports[`Data Header opens menu when menu icon is clicked 1`] = `
</ul>
`;

exports[`Data Header renders correctly 1`] = `
exports[`Data Header > renders correctly 1`] = `
<DocumentFragment>
<table>
<thead>
Expand Down

0 comments on commit f295281

Please sign in to comment.