Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update testing library #1643

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 39 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@
"@storybook/preview-api": "^8.0.5",
"@storybook/react-webpack5": "^8.0.5",
"@storybook/test-runner": "^0.17.0",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/react": "^14.1.2",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/blueimp-md5": "^2.18.2",
"@types/chroma-js": "^2.4.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {act, render, screen} from '../../../../test-utils/utils';
import {ClipboardButton} from '../ClipboardButton';

describe('ClipboardButton', () => {
Expand All @@ -28,7 +28,7 @@ describe('ClipboardButton', () => {

render(<ClipboardButton text="Text to copy" onCopy={onCopy} />);
const button = screen.getByRole('button');
button.focus();
act(() => button.focus());
await user.keyboard(key);

expect(onCopy).toHaveBeenCalledWith('Text to copy', true);
Expand Down
6 changes: 3 additions & 3 deletions test-utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const themeContextValue: ThemeContextProps = {
themeValue: 'light',
};

function Providers({children}: {children: React.ReactElement}) {
function Providers({children}: {children: React.ReactNode}) {
return <ThemeContext.Provider value={themeContextValue}>{children}</ThemeContext.Provider>;
}

function createWrapper(Component: React.JSXElementConstructor<{children: React.ReactElement}>) {
return function Wrapper({children}: {children: React.ReactElement}) {
function createWrapper(Component: React.JSXElementConstructor<{children: React.ReactNode}>) {
return function Wrapper({children}: {children: React.ReactNode}) {
return (
<Providers>
<Component>{children}</Component>
Expand Down
Loading