1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 09:58:13 +09:00

chore: update test

This commit is contained in:
2020-03-14 12:02:22 +09:00
parent e4ddd6e5e6
commit 64b40c9c8a
5 changed files with 146 additions and 80 deletions

View File

@@ -1,18 +1,17 @@
import React, {Suspense} from 'react';
import {render, waitForElement} from '@testing-library/react';
import {render} from '@testing-library/react';
import {BrowserRouter as Router} from 'react-router-dom';
import App from './App';
import 'mutationobserver-shim';
it('renders welcome message', async () => {
const {getByText} = render(
const {findByText} = render(
<Suspense fallback={<div>loading</div>}>
<Router>
<App />
</Router>
</Suspense>,
);
const text = await waitForElement(() =>
getByText('Grab a slick name for your new app'),
);
const text = await findByText('Grab a slick name for your new app');
expect(text).toBeTruthy();
});

View File

@@ -1,6 +1,7 @@
import React from 'react';
import {render, waitForDomChange} from '@testing-library/react';
import {render, waitFor} from '@testing-library/react';
import {useDeferredState} from './hooks';
import 'mutationobserver-shim';
const App: React.FC = () => {
const [value, setValue] = useDeferredState(500, 0);
@@ -13,8 +14,9 @@ const App: React.FC = () => {
};
it('provoke state flow after certain time passed', async () => {
const {container, getByTestId} = render(<App />);
const {getByTestId} = render(<App />);
expect(getByTestId('root').textContent).toBe('0');
await waitForDomChange({container});
expect(getByTestId('root').textContent).toBe('3');
await waitFor(() => {
expect(getByTestId('root').textContent).toBe('3');
});
});