feat(Alert/CommandPalette/Modal/Slideover/Toast): handle closeIcon and uniformize close prop

This commit is contained in:
Benjamin Canac
2024-06-11 15:48:45 +02:00
parent d160278283
commit e4eef89767
17 changed files with 574 additions and 311 deletions

View File

@@ -7,22 +7,26 @@ describe('Alert', () => {
const colors = Object.keys(theme.variants.color) as any
const variants = Object.keys(theme.variants.variant) as any
const props = { title: 'Alert' }
it.each([
// Props
['with title', { props: { title: 'Title' } }],
['with description', { props: { title: 'Title', description: 'Description' } }],
['with icon', { props: { title: 'Title', icon: 'i-heroicons-light-bulb' } }],
['with avatar', { props: { title: 'Title', avatar: { src: 'https://avatars.githubusercontent.com/u/739984?v=4' } } }],
['with as', { props: { title: 'Title', as: 'article' } }],
...colors.map((color: string) => [`with color ${color}`, { props: { label: 'Badge', color } }]),
...variants.map((variant: string) => [`with variant ${variant}`, { props: { label: 'Badge', color: 'primary', variant } }]),
['with class', { props: { class: 'w-48' } }],
['with ui', { props: { ui: { title: 'font-bold' } } }],
['with title', { props }],
['with description', { props: { ...props, description: 'Description' } }],
['with icon', { props: { ...props, icon: 'i-heroicons-light-bulb' } }],
['with avatar', { props: { ...props, avatar: { src: 'https://avatars.githubusercontent.com/u/739984?v=4' } } }],
['with close', { props: { ...props, close: true } }],
['with closeIcon', { props: { ...props, close: true, closeIcon: 'i-heroicons-trash' } }],
...colors.map((color: string) => [`with color ${color}`, { props: { ...props, color } }]),
...variants.map((variant: string) => [`with variant ${variant}`, { props: { ...props, color: 'primary', variant } }]),
['with as', { props: { ...props, as: 'article' } }],
['with class', { props: { ...props, class: 'w-48' } }],
['with ui', { props: { ...props, ui: { title: 'font-bold' } } }],
// Slots
['with leading slot', { slots: { title: () => 'Leading slot' } }],
['with title slot', { slots: { title: () => 'Title slot' } }],
['with description slot', { slots: { description: () => 'Description slot' } }],
['with close slot', { props: { close: true }, slots: { close: () => 'Close slot' } }]
['with leading slot', { props, slots: { title: () => 'Leading slot' } }],
['with title slot', { props, slots: { title: () => 'Title slot' } }],
['with description slot', { props, slots: { description: () => 'Description slot' } }],
['with close slot', { props, slots: { close: () => 'Close slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: AlertProps, slots?: Partial<AlertSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, Alert)
expect(html).toMatchSnapshot()