This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refactor/116 RegistryInfoContent is converted to functional comp…
…onent (#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
- Loading branch information
1 parent
803da1c
commit b74ca22
Showing
4 changed files
with
87 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 24 additions & 12 deletions
36
src/components/RegistryInfoContent/RegistryInfoContent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { render, cleanup, fireEvent } from '@testing-library/react'; | ||
|
||
import RegistryInfoContent from './RegistryInfoContent'; | ||
|
||
describe('<RegistryInfoContent /> component', () => { | ||
test('should render the component in default state with npm tab', () => { | ||
const wrapper = mount(<RegistryInfoContent registryUrl="https://registry.verdaccio.org" scope="@" />); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
afterEach(() => { | ||
cleanup(); | ||
}); | ||
|
||
test('should render the component in default state with pnpm tab', () => { | ||
const wrapper = mount(<RegistryInfoContent registryUrl="https://registry.verdaccio.org" scope="@" />); | ||
wrapper.setState({ tabPosition: 1 }); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
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 render the component in default state with yarn tab', () => { | ||
const wrapper = mount(<RegistryInfoContent registryUrl="https://registry.verdaccio.org" scope="@" />); | ||
wrapper.setState({ tabPosition: 2 }); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
src/components/RegistryInfoContent/__snapshots__/RegistryInfoContent.test.tsx.snap
This file was deleted.
Oops, something went wrong.