mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 21:16:15 +00:00
b8d0ad8fbc
* feat: update docs * feat: update docs * fix: update docs * Add files via upload * Add files via upload * Update the-first-app.md * Update the-first-app.md * Update v08-changelog.md * feat: update docs Co-authored-by: Zhou <zhou.working@gmail.com>
41 lines
1.1 KiB
Markdown
41 lines
1.1 KiB
Markdown
# 测试
|
|
|
|
测试基于 [Jest](https://jestjs.io/) 测试框架。同时还包括了常用的 React 测试库,如 [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/)
|
|
|
|
## 示例
|
|
|
|
```tsx | pure
|
|
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { MemoryRouter } from 'react-router-dom';
|
|
import { RouteSwitch } from '../RouteSwitch';
|
|
import { RouteSwitchProvider } from '../RouteSwitchProvider';
|
|
|
|
const Home = () => <h1>Home</h1>;
|
|
const About = () => <h1>About</h1>;
|
|
|
|
describe('route-switch', () => {
|
|
it('case 1', () => {
|
|
const App = () => {
|
|
return (
|
|
<RouteSwitchProvider components={{ Home, About }}>
|
|
<MemoryRouter initialEntries={['/']}>
|
|
<RouteSwitch
|
|
routes={[
|
|
{
|
|
type: 'route',
|
|
path: '/',
|
|
exact: true,
|
|
component: 'Home',
|
|
},
|
|
]}
|
|
/>
|
|
</MemoryRouter>
|
|
</RouteSwitchProvider>
|
|
);
|
|
};
|
|
const { container } = render(<App />);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
});
|
|
``` |