-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(Cell): improve unit-tests coverage (#7323)
Улучшил покрытие тестами компонента Cell и сопутствующие ему CellButton и SimpleCell, CellCheckbox
- Loading branch information
1 parent
5a0b172
commit f834700
Showing
4 changed files
with
141 additions
and
3 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
26 changes: 25 additions & 1 deletion
26
packages/vkui/src/components/Cell/CellCheckbox/CellCheckbox.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,10 +1,34 @@ | ||
import { render } from '@testing-library/react'; | ||
import { Platform } from '../../../lib/platform'; | ||
import { baselineComponent } from '../../../testing/utils'; | ||
import { CellCheckbox } from './CellCheckbox'; | ||
import { ConfigProvider } from '../../ConfigProvider/ConfigProvider'; | ||
import { CellCheckbox, CellCheckboxProps } from './CellCheckbox'; | ||
import styles from './CellCheckbox.module.css'; | ||
|
||
describe('CellCheckbox', () => { | ||
baselineComponent((props) => ( | ||
<label> | ||
CellCheckbox <CellCheckbox {...props} /> | ||
</label> | ||
)); | ||
|
||
describe.each([Platform.IOS, Platform.VKCOM])( | ||
'should use circle icon in platform %s', | ||
(platform) => { | ||
it.each<CellCheckboxProps['type']>(['auto', 'circle'])('with type %s ', (type) => { | ||
const { container } = render( | ||
<ConfigProvider platform={platform}> | ||
<CellCheckbox type={type} /> | ||
</ConfigProvider>, | ||
); | ||
const iconsOff = container.getElementsByClassName(styles['CellCheckbox__icon--off'])[0]; | ||
expect(iconsOff.querySelector('.vkuiIcon--check_circle_off_20')).toBeInTheDocument(); | ||
expect(iconsOff.querySelector('.vkuiIcon--check_circle_off_24')).toBeInTheDocument(); | ||
|
||
const iconsOn = container.getElementsByClassName(styles['CellCheckbox__icon--on'])[0]; | ||
expect(iconsOn.querySelector('.vkuiIcon--check_circle_on_20')).toBeInTheDocument(); | ||
expect(iconsOn.querySelector('.vkuiIcon--check_circle_on_24')).toBeInTheDocument(); | ||
}); | ||
}, | ||
); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/vkui/src/components/CellButton/CellButton.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,6 +1,25 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { baselineComponent } from '../../testing/utils'; | ||
import { CellButton } from './CellButton'; | ||
import styles from './CellButton.module.css'; | ||
|
||
describe('CellButton', () => { | ||
baselineComponent((props) => <CellButton {...props}>CellButton</CellButton>); | ||
|
||
it('should have danger className with mode danger', () => { | ||
render( | ||
<CellButton mode="danger" data-testid="cell"> | ||
Check | ||
</CellButton>, | ||
); | ||
expect(screen.getByTestId('cell')).toHaveClass(styles['CellButton--mode-danger']); | ||
}); | ||
it('should have danger className with mode danger', () => { | ||
render( | ||
<CellButton centered data-testid="cell"> | ||
Check | ||
</CellButton>, | ||
); | ||
expect(screen.getByTestId('cell')).toHaveClass(styles['CellButton--centered']); | ||
}); | ||
}); |
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