-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AspectRatio): extract ratio prop type (#8088)
- Loading branch information
1 parent
86648b8
commit 5cb14c4
Showing
13 changed files
with
46 additions
and
24 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
19 changes: 19 additions & 0 deletions
19
packages/vkui/src/components/AspectRatio/AspectRatio.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 { AspectRatio } from './AspectRatio'; | ||
import styles from './AspectRatio.module.css'; | ||
|
||
describe(AspectRatio, () => { | ||
baselineComponent(AspectRatio); | ||
|
||
it('check mode stretch has specific className', () => { | ||
render(<AspectRatio data-testid="ratio" ratio={16 / 9} mode="stretch" />); | ||
expect(screen.getByTestId('ratio')).toHaveClass(styles.modeStretch); | ||
}); | ||
|
||
it('check using custom ratio', () => { | ||
const { rerender } = render( | ||
<AspectRatio data-testid="ratio" ratio="var(--custom-aspect-ratio-var)" />, | ||
); | ||
expect(screen.getByTestId('ratio')).toHaveStyle( | ||
'--vkui_internal--aspect_ratio: var(--custom-aspect-ratio-var);', | ||
); | ||
|
||
rerender(<AspectRatio data-testid="ratio" ratio="calc(16 / 9)" />); | ||
expect(screen.getByTestId('ratio')).toHaveStyle('--vkui_internal--aspect_ratio: calc(16 / 9);'); | ||
}); | ||
}); |
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
4 changes: 2 additions & 2 deletions
4
...ts/AspectRatio/__image_snapshots__/aspectratio-android-chromium-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...s/AspectRatio/__image_snapshots__/aspectratio-android-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...mponents/AspectRatio/__image_snapshots__/aspectratio-ios-webkit-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ponents/AspectRatio/__image_snapshots__/aspectratio-ios-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ents/AspectRatio/__image_snapshots__/aspectratio-vkcom-chromium-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...nts/AspectRatio/__image_snapshots__/aspectratio-vkcom-chromium-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...nents/AspectRatio/__image_snapshots__/aspectratio-vkcom-firefox-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ents/AspectRatio/__image_snapshots__/aspectratio-vkcom-firefox-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...onents/AspectRatio/__image_snapshots__/aspectratio-vkcom-webkit-dark-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...nents/AspectRatio/__image_snapshots__/aspectratio-vkcom-webkit-light-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.