mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-22 16:00:39 +01:00
feat(ButtonGroup): new component (#88)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
47
test/components/ButtonGroup.spec.ts
Normal file
47
test/components/ButtonGroup.spec.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import ButtonGroup, { type ButtonGroupProps, type ButtonGroupSlots } from '../../src/runtime/components/ButtonGroup.vue'
|
||||
import ComponentRender from '../component-render'
|
||||
import { UInput, UButton } from '#components'
|
||||
import buttonTheme from '#build/ui/button'
|
||||
|
||||
describe('ButtonGroup', () => {
|
||||
const sizes = Object.keys(buttonTheme.variants.size) as any
|
||||
|
||||
it.each([
|
||||
// Props
|
||||
['with as', { props: { as: 'div' } }],
|
||||
['with class', { props: { class: '' } }],
|
||||
['with ui', { props: { ui: {} } }],
|
||||
// Slots
|
||||
['with default slot', {
|
||||
slots: {
|
||||
default: {
|
||||
components: { UInput, UButton },
|
||||
template: `<UInput /> <UButton> Click me! </UButton>`
|
||||
}
|
||||
}
|
||||
}],
|
||||
['orientation vertical with default slot', {
|
||||
props: { orientation: 'vertical' },
|
||||
slots: {
|
||||
default: {
|
||||
components: { UInput, UButton },
|
||||
template: `<UInput /> <UButton> Click me! </UButton>`
|
||||
}
|
||||
}
|
||||
}],
|
||||
...sizes.map((size: string) =>
|
||||
[`with size ${size}`, { props: { size },
|
||||
slots: {
|
||||
default: {
|
||||
components: { UInput, UButton },
|
||||
template: `<UInput /> <UButton> Click me! </UButton>`
|
||||
}
|
||||
}
|
||||
}]
|
||||
)
|
||||
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ButtonGroupProps, slots?: Partial<ButtonGroupSlots> }) => {
|
||||
const html = await ComponentRender(nameOrHtml, options, ButtonGroup)
|
||||
expect(html).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user