mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 02:10:40 +01:00
test(Button): import from #components
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
// @vitest-environment nuxt
|
|
||||||
import { describe, it, expect } from 'vitest'
|
import { describe, it, expect } from 'vitest'
|
||||||
import Button from '../../src/runtime/components/elements/Button.vue'
|
import { UButton } from '#components'
|
||||||
import type { TypeOf } from 'zod'
|
import type { TypeOf } from 'zod'
|
||||||
import ComponentRender from '../component-render'
|
import ComponentRender from '../component-render'
|
||||||
|
|
||||||
type ButtonOptions = TypeOf<typeof Button.props>
|
|
||||||
|
|
||||||
describe('Button', () => {
|
describe('Button', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[ 'basic case', { } ],
|
[ 'basic case', { } ],
|
||||||
@@ -14,12 +11,12 @@ describe('Button', () => {
|
|||||||
[ 'rounded full', { props: { ui: { rounded: 'rounded-full' } } } ],
|
[ 'rounded full', { props: { ui: { rounded: 'rounded-full' } } } ],
|
||||||
[ '<UButton icon="i-heroicons-pencil-square" size="sm" color="primary" square variant="solid" />' ]
|
[ '<UButton icon="i-heroicons-pencil-square" size="sm" color="primary" square variant="solid" />' ]
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
])('renders %s correctly', async (nameOrHtml: string, options: ButtonOptions) => {
|
])('renders %s correctly', async (nameOrHtml: string, options: TypeOf<typeof Button.props>) => {
|
||||||
if (options !== undefined) {
|
if (options !== undefined) {
|
||||||
options.slots = options.slots || { default: () => 'label' }
|
options.slots = options.slots || { default: () => 'label' }
|
||||||
options.slots.default = options.slots.default || (() => 'label')
|
options.slots.default = options.slots.default || (() => 'label')
|
||||||
}
|
}
|
||||||
const html = await ComponentRender(nameOrHtml, options, Button)
|
const html = await ComponentRender(nameOrHtml, options, UButton)
|
||||||
expect(html).toMatchSnapshot()
|
expect(html).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user