mirror of
https://github.com/SomboChea/ui
synced 2024-11-11 00:54:26 +07:00
111f0c50e5
* chore: updated emotion dependency * feat: introduced theme * refactor: updated emotion styles * fix: fixed emotion error * fix: fixed tests * chore: add missing types Co-Authored-By: Thomas Klein <tmkn@users.noreply.github.com>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import React from 'react';
|
||
|
||
import { render, cleanup, fireEvent } from '../../utils/test-react-testing-library';
|
||
|
||
import RegistryInfoContent from './RegistryInfoContent';
|
||
|
||
describe('<RegistryInfoContent /> component', () => {
|
||
afterEach(() => {
|
||
cleanup();
|
||
});
|
||
|
||
test('should load the component with no data', () => {
|
||
const { getByTestId } = render(<RegistryInfoContent registryUrl={''} scope={''} />);
|
||
const unorderedListOfTodos = getByTestId('tabs-el');
|
||
expect(unorderedListOfTodos.children.length).toBe(1);
|
||
});
|
||
|
||
test('should load the appropiate tab content when the tab is clicked', () => {
|
||
const props = { registryUrl: 'http://localhost:4872', scope: '@' };
|
||
const pnpmTabTextContent = `pnpm adduser --registry ${props.registryUrl}`;
|
||
|
||
// Render the component.
|
||
const { container, getByTestId } = render(
|
||
<RegistryInfoContent registryUrl={props.registryUrl} scope={props.scope} />
|
||
);
|
||
|
||
// Assert the text content for pnpm tab is not present intially
|
||
expect(container.textContent).not.toContain(pnpmTabTextContent);
|
||
|
||
const pnpmTab = getByTestId('pnpm-tab');
|
||
fireEvent.click(pnpmTab);
|
||
|
||
// Assert the text content is correct after clicking on the tab.
|
||
expect(container.textContent).toContain(pnpmTabTextContent);
|
||
});
|
||
});
|