feat(Form): new component (#4)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2024-03-19 16:09:12 +01:00
committed by GitHub
parent 1cec712fb8
commit de62676647
35 changed files with 2735 additions and 69 deletions

View File

@@ -0,0 +1,28 @@
import { describe, it, expect } from 'vitest'
import Input, { type InputProps } from '../../src/runtime/components/Input.vue'
import ComponentRender from '../component-render'
describe('Input', () => {
it.each([
['basic case', {}],
['with name', { props: { name: 'username' } }],
['with type', { props: { type: 'password' } }],
['with placeholder', { props: { placeholder: 'Enter your username' } }],
['with disabled', { props: { disabled: true } }],
['with required', { props: { required: true } }],
// ['with icon', { props: { icon: 'i-heroicons-battery-50-solid' } }],
// ['with leading and icon', { props: { leading: true, icon: 'i-heroicons-battery-50-solid' } }],
// ['with leadingIcon', { props: { leadingIcon: 'i-heroicons-battery-50-solid' } }],
// ['with loading icon', { props: { loading: true } }],
// ['with leading slot', { slots: { leading: () => 'leading slot' } }],
// ['with trailing and icon', { props: { trailing: true, icon: 'i-heroicons-battery-50-solid' } }],
// ['with trailingIcon', { props: { trailingIcon: 'i-heroicons-battery-50-solid' } }],
// ['with trailing slot', { slots: { leading: () => 'trailing slot' } }],
['with size', { props: { size: 'xs' as const } }],
['with color', { props: { color: 'red' as const } }],
['with variant', { props: { variant: 'outline' as const } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: InputProps, slots?: any }) => {
const html = await ComponentRender(nameOrHtml, options, Input)
expect(html).toMatchSnapshot()
})
})