tachybase_todo/docs/tr-TR/development/client/test.md
altaytahsin ad4929e48b
Turkish language created for Docs. Belgeler için türkçe dil desteği (#1071)
* Turkish language created for Docs. Belgeler için türkçe dil desteği oluşturuldu.

* Turkish docs fix
2022-12-23 09:42:44 +08:00

1.2 KiB

Testing

Testing is based on the Jest testing framework. Also included are common React testing libraries such as @testing-library/react

Example

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();
  });
});