1
0
Fork 1
mirror of https://github.com/SomboChea/ui synced 2024-06-18 17:29:43 +07:00
verdaccio-ui/src/components/RegistryInfoContent/RegistryInfoContent.test.tsx
Alfonso Austin b74ca2285e fix: refactor/116 RegistryInfoContent is converted to functional component (#229)
* refactor:116[PackageList] component is converted to functional

* Refactor:#116 - Registry info content is converted to functional component

* refactor/116 - fix lint error

* refactor:116 - more lint errors

* refactor/116 - lint error

* refactor:116 - remove snapshot

* refactor: address code review comments #116

* refactor: fix lint error

* refactor: code review changes

* refactor add missed file

* refactor: lint error

* refactor: lint

* refactor: lint

* refactor: fix lint error
2019-11-02 17:53:21 +01:00

36 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import { render, cleanup, fireEvent } from '@testing-library/react';
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);
});
});