1
0
mirror of https://github.com/uetchy/namae.git synced 2025-10-14 23:22:19 +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

@@ -36,10 +36,10 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^5.1.1",
"@testing-library/react": "^9.4.1",
"@testing-library/react": "^10.0.1",
"@types/i18next-node-fs-backend": "^2.1.0",
"@types/jest": "^25.1.3",
"@types/node": "^13.7.4",
"@types/jest": "^25.1.4",
"@types/node": "^13.9.1",
"@types/react-helmet": "^5.0.15",
"@types/react-router-dom": "^5.1.3",
"@types/styled-components": "^5.0.0",
@@ -48,7 +48,8 @@
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-react": "^7.18.3",
"husky": "^4.2.3",
"i18next-node-fs-backend": "^2.1.3"
"i18next-node-fs-backend": "^2.1.3",
"mutationobserver-shim": "^0.3.3"
},
"browserslist": {
"production": [

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