-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(HorizontalMosaic, VerticalMosaic): allow passing gridMode inform…
…ation to each item (#1289) Issue: [Link](https://jira.tid.es/browse/WEB-2092)
- Loading branch information
1 parent
007f4f8
commit bb8852c
Showing
2 changed files
with
118 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import * as React from 'react'; | ||
import {render, screen} from '@testing-library/react'; | ||
import ThemeContextProvider from '../theme-context-provider'; | ||
import {makeTheme} from './test-utils'; | ||
import {HorizontalMosaic, VerticalMosaic} from '../mosaic'; | ||
import {Text2} from '../text'; | ||
|
||
const ITEMS_COUNT = [1, 2, 3, 4, 5, 6]; | ||
|
||
const verticalMosaicItemsGridMode = [ | ||
// 1 item | ||
['horizontal'], | ||
|
||
// 2 items | ||
['square', 'square'], | ||
|
||
// 3 items | ||
['vertical', 'square', 'square'], | ||
|
||
// 4 items | ||
['vertical', 'square', 'square', 'vertical'], | ||
|
||
// 5 items | ||
['vertical', 'square', 'square', 'vertical', 'horizontal'], | ||
|
||
// 6 items | ||
['vertical', 'square', 'square', 'vertical', 'square', 'square'], | ||
]; | ||
|
||
const horizontalMosaicItemsGridMode = [ | ||
// 1 item | ||
['horizontal'], | ||
|
||
// 2 items | ||
['horizontal', 'horizontal'], | ||
|
||
// 3 items | ||
['horizontal', 'square', 'square'], | ||
|
||
// 4 items | ||
['square', 'square', 'square', 'square'], | ||
|
||
// 5 items | ||
['horizontal', 'square', 'square', 'horizontal', 'horizontal'], | ||
|
||
// 6 items | ||
['horizontal', 'square', 'square', 'square', 'square', 'horizontal'], | ||
]; | ||
|
||
test.each(ITEMS_COUNT)( | ||
'VerticalMosaic - gridMode passed as a function is correct with %s items', | ||
(itemsCount) => { | ||
render( | ||
<ThemeContextProvider theme={makeTheme()}> | ||
<VerticalMosaic | ||
items={Array.from({length: itemsCount}, (_, index) => ({gridMode}) => ( | ||
<Text2 regular>{`${index + 1}-${gridMode}`}</Text2> | ||
))} | ||
/> | ||
</ThemeContextProvider> | ||
); | ||
|
||
const expectedGridModes = verticalMosaicItemsGridMode[itemsCount - 1]; | ||
|
||
expectedGridModes.forEach((gridMode, index) => { | ||
expect(screen.getByText(`${index + 1}-${gridMode}`)).toBeInTheDocument(); | ||
}); | ||
} | ||
); | ||
|
||
test.each(ITEMS_COUNT)( | ||
'HorizontalMosaic - gridMode passed as a function is correct with %s items', | ||
(itemsCount) => { | ||
render( | ||
<ThemeContextProvider theme={makeTheme()}> | ||
<HorizontalMosaic | ||
items={Array.from({length: itemsCount}, (_, index) => ({gridMode}) => ( | ||
<Text2 regular>{`${index + 1}-${gridMode}`}</Text2> | ||
))} | ||
/> | ||
</ThemeContextProvider> | ||
); | ||
|
||
const expectedGridModes = horizontalMosaicItemsGridMode[itemsCount - 1]; | ||
|
||
expectedGridModes.forEach((gridMode, index) => { | ||
expect(screen.getByText(`${index + 1}-${gridMode}`)).toBeInTheDocument(); | ||
}); | ||
} | ||
); |
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
bb8852c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for mistica-web ready!
✅ Preview
https://mistica-165ykx4zh-flows-projects-65bb050e.vercel.app
Built with commit bb8852c.
This pull request is being automatically deployed with vercel-action