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:
@@ -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();
|
||||
});
|
||||
|
@@ -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');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user