Implement testing library (#2)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Co-authored-by: Eric NGUYEN <enguyen@techform.fr> Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/2
This commit is contained in:
parent
081d65b62b
commit
1f1babe49f
10 changed files with 2722 additions and 6 deletions
19
src/Components/Sidebar/Sidebar.test.tsx
Normal file
19
src/Components/Sidebar/Sidebar.test.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as React from 'react';
|
||||
import { describe, test, expect } from 'vitest';
|
||||
import { render, screen } from '../../utils/test-utils';
|
||||
import Sidebar from './Sidebar';
|
||||
|
||||
describe('Sidebar test', () => {
|
||||
test('Start empty', () => {
|
||||
render(
|
||||
<Sidebar
|
||||
componentOptions={[]}
|
||||
isOpen={true}
|
||||
onClick={() => {}}
|
||||
buttonOnClick={() => {}}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText(/Components/i)).toBeDefined();
|
||||
});
|
||||
});
|
1
src/test/setup.ts
Normal file
1
src/test/setup.ts
Normal file
|
@ -0,0 +1 @@
|
|||
import '@testing-library/jest-dom';
|
20
src/utils/test-utils.tsx
Normal file
20
src/utils/test-utils.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* eslint-disable import/export */
|
||||
import * as React from 'react';
|
||||
import { cleanup, render } from '@testing-library/react';
|
||||
import { afterEach } from 'vitest';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
|
||||
const customRender = (ui: React.ReactElement, options = {}) =>
|
||||
render(ui, {
|
||||
// wrap provider(s) here if needed
|
||||
wrapper: ({ children }) => children,
|
||||
...options
|
||||
});
|
||||
|
||||
export * from '@testing-library/react';
|
||||
export { default as userEvent } from '@testing-library/user-event';
|
||||
// override render export
|
||||
export { customRender as render };
|
Loading…
Add table
Add a link
Reference in a new issue