redux-devtools/packages/redux-devtools-ui/test/Tabs.test.tsx

54 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2019-01-03 16:00:55 +03:00
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
2019-01-03 16:00:55 +03:00
import { Tabs } from '../src';
import { tabs, simple10Tabs } from '../src/Tabs/data';
2019-01-03 16:00:55 +03:00
describe('Tabs', function () {
2019-01-03 16:00:55 +03:00
it('renders correctly', () => {
const { container } = render(
<Tabs
tabs={tabs}
onClick={() => {
// noop
}}
/>,
);
expect(container.firstChild).toMatchSnapshot();
2019-01-03 16:00:55 +03:00
});
it('renders with props', () => {
const { container } = render(
<Tabs
tabs={tabs}
onClick={() => {
// noop
}}
selected="Tab2"
/>,
2019-01-03 16:00:55 +03:00
);
expect(container.firstChild).toMatchSnapshot();
2019-01-03 16:00:55 +03:00
});
it('renders tabs without inner components', () => {
const { container } = render(
<Tabs
tabs={simple10Tabs}
onClick={() => {
// noop
}}
selected="5"
/>,
2019-01-03 16:00:55 +03:00
);
expect(container.firstChild).toMatchSnapshot();
2019-01-03 16:00:55 +03:00
});
it('should select tab', async () => {
2019-01-03 16:00:55 +03:00
const onClick = jest.fn();
render(<Tabs tabs={tabs} onClick={onClick} />);
2019-01-03 16:00:55 +03:00
await userEvent.click(screen.getByRole('button', { name: 'Tab1' }));
expect(onClick).toHaveBeenCalled();
2019-01-03 16:00:55 +03:00
});
});