init test and snapshot,
This commit is contained in:
35
002_source/cms/src/__tests__/__snapshots__/snapshot.js.snap
Normal file
35
002_source/cms/src/__tests__/__snapshots__/snapshot.js.snap
Normal file
@@ -0,0 +1,35 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renders homepage unchanged 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="MuiBox-root css-0"
|
||||
>
|
||||
hello world!
|
||||
|
||||
<div
|
||||
class="MuiBox-root css-0"
|
||||
>
|
||||
<p
|
||||
class="MuiTypography-root MuiTypography-body1 css-1kivl2a-MuiTypography-root"
|
||||
>
|
||||
inner component
|
||||
</p>
|
||||
<div
|
||||
class="MuiListItemIcon-root css-cveggr-MuiListItemIcon-root"
|
||||
/>
|
||||
<svg
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 256 256"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
21
002_source/cms/src/__tests__/app/_helloworld/page.test.tsx
Normal file
21
002_source/cms/src/__tests__/app/_helloworld/page.test.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference types="jest" />
|
||||
import '@testing-library/jest-dom';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import Page from '@/app/_helloworld/page';
|
||||
|
||||
// Mock the translation hook
|
||||
jest.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('Page', () => {
|
||||
it('renders a heading', () => {
|
||||
render(<Page hello={'world'} />);
|
||||
|
||||
const heading = screen.getByRole('heading', { level: 1 });
|
||||
|
||||
expect(heading).toBeInTheDocument();
|
||||
});
|
||||
});
|
9
002_source/cms/src/__tests__/snapshot.js
Normal file
9
002_source/cms/src/__tests__/snapshot.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
// CUT = Component Under Test
|
||||
import CUT from '../components/_helloworld';
|
||||
|
||||
it('renders homepage unchanged', () => {
|
||||
const { container } = render(<CUT />);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
Reference in New Issue
Block a user