-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE(web-react): Remove action colors from Pill #DS-1446
- Loading branch information
Showing
6 changed files
with
25 additions
and
32 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
28 changes: 13 additions & 15 deletions
28
packages/web-react/src/components/Pill/__tests__/Pill.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,41 +1,39 @@ | ||
import '@testing-library/jest-dom'; | ||
import { render } from '@testing-library/react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest'; | ||
import { actionColorPropsTest, emotionColorPropsTest } from '../../../../tests/providerTests/dictionaryPropsTest'; | ||
import { emotionColorPropsTest } from '../../../../tests/providerTests/dictionaryPropsTest'; | ||
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest'; | ||
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest'; | ||
import Pill from '../Pill'; | ||
|
||
describe('Pill', () => { | ||
classNamePrefixProviderTest(Pill, 'Pill'); | ||
|
||
actionColorPropsTest(Pill, 'Pill--'); | ||
|
||
emotionColorPropsTest(Pill, 'Pill--'); | ||
|
||
stylePropsTest(Pill); | ||
|
||
restPropsTest(Pill, 'span'); | ||
|
||
it('should have default classname', () => { | ||
const dom = render(<Pill />); | ||
render(<Pill data-testid="pill" />); | ||
|
||
const element = dom.container.querySelector('span') as HTMLElement; | ||
expect(element).toHaveClass('Pill--selected'); | ||
expect(screen.getByTestId('pill')).toHaveClass('Pill--selected'); | ||
}); | ||
|
||
it('should render text children', () => { | ||
const dom = render(<Pill>3</Pill>); | ||
render(<Pill>3</Pill>); | ||
|
||
const element = dom.container.querySelector('span') as HTMLElement; | ||
expect(element.textContent).toBe('3'); | ||
expect(screen.getByText(3)).toBeInTheDocument(); | ||
}); | ||
|
||
it.each([['selected'], ['unselected']])('should render color %s', (color) => { | ||
const dom = render(<Pill color={color}>333</Pill>); | ||
it.each([['selected'], ['neutral'], ['danger'], ['informative'], ['success'], ['warning']])( | ||
'should render color %s', | ||
(color) => { | ||
render(<Pill color={color}>333</Pill>); | ||
|
||
const element = dom.container.querySelector('span') as HTMLElement; | ||
expect(element).toHaveClass(`Pill--${color}`); | ||
}); | ||
expect(screen.getByText(333)).toHaveClass(`Pill--${color}`); | ||
}, | ||
); | ||
}); |
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
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
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
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