mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
30 lines
858 B
TypeScript
30 lines
858 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { ComponentOptions } from 'vue'
|
|
import { defineComponent, h, toDisplayString, useAttrs } from 'vue'
|
|
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
import { createClientOnly } from '../../packages/nuxt/src/app/components/client-only'
|
|
|
|
const Client = defineComponent({
|
|
name: 'TestClient',
|
|
setup () {
|
|
const attrs = useAttrs()
|
|
return () => h('div', {}, toDisplayString(attrs))
|
|
},
|
|
})
|
|
|
|
describe('createClient attribute inheritance', () => {
|
|
it('should retrieve attributes with useAttrs()', async () => {
|
|
const wrapper = await mountSuspended(createClientOnly(Client as ComponentOptions), {
|
|
attrs: {
|
|
id: 'client',
|
|
},
|
|
})
|
|
|
|
expect(wrapper.html()).toMatchInlineSnapshot(`
|
|
"<div id="client">{
|
|
"id": "client"
|
|
}</div>"
|
|
`)
|
|
})
|
|
})
|