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: migrate to react-testing library #570

Merged
merged 1 commit into from
Dec 18, 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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"react-dom": "18.3.1",
"react-live": "4.1.8",
"react-modal": "3.16.3",
"react-test-renderer": "18.3.1",
"webpack": "5.97.1",
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.2.0"
Expand Down
26 changes: 0 additions & 26 deletions pnpm-lock.yaml

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

5 changes: 3 additions & 2 deletions src/components/__tests__/Tab-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { render } from '@testing-library/react';
import Tab from '../Tab';
import { TabWrapper } from './helpers/higherOrder';

function expectToMatchSnapshot(component) {
expect(renderer.create(component).toJSON()).toMatchSnapshot();
const { container } = render(component);
expect(container.firstChild).toMatchSnapshot();
}

describe('<Tab />', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/__tests__/TabList-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { render } from '@testing-library/react';
import Tab from '../Tab';
import TabList from '../TabList';
import TabPanel from '../TabPanel';
Expand All @@ -16,7 +16,8 @@ jest.mock('react', () => {
});

function expectToMatchSnapshot(component) {
expect(renderer.create(component).toJSON()).toMatchSnapshot();
const { container } = render(component);
expect(container.firstChild).toMatchSnapshot();
}

describe('<TabList />', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/__tests__/TabPanel-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { render } from '@testing-library/react';
import TabPanel from '../TabPanel';
import { TabPanelWrapper } from './helpers/higherOrder';

function expectToMatchSnapshot(component) {
expect(renderer.create(component).toJSON()).toMatchSnapshot();
const { container } = render(component);
expect(container.firstChild).toMatchSnapshot();
}

describe('<TabPanel />', () => {
Expand Down
53 changes: 23 additions & 30 deletions src/components/__tests__/__snapshots__/Tab-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ exports[`<Tab /> override the tabIndex if it was provided 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="false"
className="react-tabs__tab"
data-rttab={true}
class="react-tabs__tab"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex="0"
tabindex="0"
>
Hello
</li>
Expand All @@ -20,11 +20,10 @@ exports[`<Tab /> should accept className 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="false"
className="foobar"
data-rttab={true}
class="foobar"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -33,11 +32,10 @@ exports[`<Tab /> should allow to be wrapped in higher-order-component 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="false"
className="react-tabs__tab"
data-rttab={true}
class="react-tabs__tab"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -46,11 +44,10 @@ exports[`<Tab /> should have sane defaults 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="false"
className="react-tabs__tab"
data-rttab={true}
class="react-tabs__tab"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -59,11 +56,10 @@ exports[`<Tab /> should not allow overriding all default properties 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="false"
className="react-tabs__tab"
data-rttab={true}
class="react-tabs__tab"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -72,12 +68,11 @@ exports[`<Tab /> should pass through custom properties 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="false"
className="react-tabs__tab"
data-rttab={true}
class="react-tabs__tab"
data-rttab="true"
data-tooltip="Tooltip contents"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -86,11 +81,10 @@ exports[`<Tab /> should support being disabled 1`] = `
aria-controls="panelnull"
aria-disabled="true"
aria-selected="false"
className="react-tabs__tab react-tabs__tab--disabled"
data-rttab={true}
class="react-tabs__tab react-tabs__tab--disabled"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -99,11 +93,10 @@ exports[`<Tab /> should support being disabled with custom class name 1`] = `
aria-controls="panelnull"
aria-disabled="true"
aria-selected="false"
className="react-tabs__tab coolDisabled"
data-rttab={true}
class="react-tabs__tab coolDisabled"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex={null}
/>
`;

Expand All @@ -112,11 +105,11 @@ exports[`<Tab /> should support being selected 1`] = `
aria-controls="panelabcd"
aria-disabled="false"
aria-selected="true"
className="react-tabs__tab react-tabs__tab--selected"
data-rttab={true}
class="react-tabs__tab react-tabs__tab--selected"
data-rttab="true"
id="tababcd"
role="tab"
tabIndex="0"
tabindex="0"
>
Hello
</li>
Expand All @@ -127,10 +120,10 @@ exports[`<Tab /> should support being selected with custom class 1`] = `
aria-controls="panelnull"
aria-disabled="false"
aria-selected="true"
className="react-tabs__tab cool"
data-rttab={true}
class="react-tabs__tab cool"
data-rttab="true"
id="tabnull"
role="tab"
tabIndex="0"
tabindex="0"
/>
`;
Loading
Loading