mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 19:30:37 +01:00
test(Input): use mount to access defineModel events
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { describe, it, expect, test } from 'vitest'
|
import { describe, it, expect, test } from 'vitest'
|
||||||
import Input, { type InputProps } from '../../src/runtime/components/Input.vue'
|
import Input, { type InputProps } from '../../src/runtime/components/Input.vue'
|
||||||
import ComponentRender from '../component-render'
|
import ComponentRender from '../component-render'
|
||||||
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
import { mount } from '@vue/test-utils'
|
||||||
|
|
||||||
describe('Input', () => {
|
describe('Input', () => {
|
||||||
it.each([
|
it.each([
|
||||||
@@ -32,13 +32,12 @@ describe('Input', () => {
|
|||||||
expect(html).toMatchSnapshot()
|
expect(html).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
// See: https://github.com/nuxt/test-utils/issues/572
|
it.each([
|
||||||
it.skip.each([
|
|
||||||
['with .trim modifier', { props: { modelModifiers: { trim: true } } }, { input: 'input ', expected: 'input' } ],
|
['with .trim modifier', { props: { modelModifiers: { trim: true } } }, { input: 'input ', expected: 'input' } ],
|
||||||
['with .number modifier', { props: { modelModifiers: { number: true } } }, { input: '42', expected: 42 } ],
|
['with .number modifier', { props: { modelModifiers: { number: true } } }, { input: '42', expected: 42 } ],
|
||||||
['with .lazy modifier', { props: { modelModifiers: { lazy: true } } }, { input: 'input', expected: 'input' } ]
|
['with .lazy modifier', { props: { modelModifiers: { lazy: true } } }, { input: 'input', expected: 'input' } ]
|
||||||
])('%s works', async (_nameOrHtml: string, options: { props?: any, slots?: any }, spec: { input: any, expected: any }) => {
|
])('%s works', async (_nameOrHtml: string, options: { props?: any, slots?: any }, spec: { input: any, expected: any }) => {
|
||||||
const wrapper = await mountSuspended(Input, {
|
const wrapper = mount(Input, {
|
||||||
...options
|
...options
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -48,9 +47,8 @@ describe('Input', () => {
|
|||||||
expect(wrapper.emitted()).toMatchObject({ 'update:modelValue': [[spec.expected]] })
|
expect(wrapper.emitted()).toMatchObject({ 'update:modelValue': [[spec.expected]] })
|
||||||
})
|
})
|
||||||
|
|
||||||
// See: https://github.com/nuxt/test-utils/issues/572
|
test('with .lazy modifier updates on change only', async () => {
|
||||||
test.skip('with .lazy modifier updates on change only', async () => {
|
const wrapper = mount(Input, {
|
||||||
const wrapper = await mountSuspended(Input, {
|
|
||||||
props: {
|
props: {
|
||||||
modelModifiers: { lazy: true }
|
modelModifiers: { lazy: true }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user