Skip to content

Commit

Permalink
test: add failing test for setProps
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 6, 2023
1 parent 84d67f1 commit dc93e00
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { describe, expect, it } from 'vitest'
import { beforeEach, describe, expect, it } from 'vitest'

import { mountSuspended } from '@nuxt/test-utils/runtime-utils'

import App from '~/app.vue'
import OptionsComponent from '~/components/OptionsComponent.vue'
import WrapperTests from '~/components/WrapperTests.vue'

import type { VueWrapper} from '@vue/test-utils';
import { mount } from '@vue/test-utils'

import ExportDefaultComponent from '~/components/ExportDefaultComponent.vue'
Expand Down Expand Up @@ -110,15 +111,33 @@ describe('mountSuspended', () => {
})

describe.each(Object.entries(formats))(`%s`, (name, component) => {
it('mounts with props', async () => {
const wrapper = await mountSuspended(component, {
let wrapper: VueWrapper<any>

beforeEach(async () => {
wrapper = await mountSuspended(component, {
props: {
myProp: 'Hello nuxt-vitest',
},
})
})

it('mounts with props', () => {
expect(wrapper.html()).toEqual(`
<div>
<h1>${name}</h1><pre>Hello nuxt-vitest</pre><pre>XHello nuxt-vitest</pre>
</div>
`.trim())
})

// FIXME: https://github.com/nuxt/test-utils/issues/534
it.todo('can be updated with setProps', async () => {
wrapper.setProps({
title: 'updated title'
})
await nextTick()
expect(wrapper.html()).toEqual(`
<div>
<h1>${name}</h1><pre>updated title</pre><pre>XHello nuxt-vitest</pre>
</div>
`.trim())
})
Expand Down

0 comments on commit dc93e00

Please sign in to comment.