Files
vitify-nuxt/tests/component.nuxt.test.ts
2025-04-22 10:56:56 +07:00

25 lines
885 B
TypeScript

import { describe, expect, it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import DialogConfirm from '~/components/DialogConfirm.vue'
import { VCard } from 'vuetify/components'
describe('component DialogConfirm.vue', () => {
it('should not open', async () => {
const wrapper = await mountSuspended(DialogConfirm)
expect(wrapper.html()).toMatchInlineSnapshot(`""`)
})
it('should open and close', async () => {
const wrapper = await mountSuspended(DialogConfirm)
wrapper.vm.open('message')
await nextTick()
const cardWrapper = wrapper.getComponent(VCard)
expect(cardWrapper.text()).toContain('message')
expect(cardWrapper.html()).toMatchSnapshot()
expect(cardWrapper.find('button').exists()).toBe(true)
await cardWrapper.find('button').trigger('click')
expect(cardWrapper.isVisible()).toBe(false)
})
})