test(nuxt): add test for data-island-uid replacement (#25346)

This commit is contained in:
Julien Huang 2024-01-21 12:30:54 +01:00 committed by GitHub
parent 013845f636
commit 83c9146af3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,4 +201,41 @@ describe('client components', () => {
vi.mocked(fetch).mockReset() vi.mocked(fetch).mockReset()
expectNoConsoleIssue() expectNoConsoleIssue()
}) })
it('should not replace nested client components data-island-uid', async () => {
const componentId = 'Client-12345'
const stubFetch = vi.fn(() => {
return {
id: '1234',
html: `<div data-island-uid>hello<div data-island-uid="not-to-be-replaced" data-island-component="${componentId}"></div></div>`,
state: {},
head: {
link: [],
style: []
},
json() {
return this
}
}
})
vi.stubGlobal('fetch', stubFetch)
const wrapper = await mountSuspended(NuxtIsland, {
props: {
name: 'WithNestedClient',
props: {
force: true
}
},
attachTo: 'body'
})
expect(fetch).toHaveBeenCalledOnce()
expect(wrapper.html()).toContain('data-island-uid="not-to-be-replaced"')
vi.mocked(fetch).mockReset()
expectNoConsoleIssue()
})
}) })