From 83c9146af31e883e53fa8dbfe7d30b4090ca3dce Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Sun, 21 Jan 2024 12:30:54 +0100 Subject: [PATCH] test(nuxt): add test for `data-island-uid` replacement (#25346) --- test/nuxt/nuxt-island.test.ts | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/nuxt/nuxt-island.test.ts b/test/nuxt/nuxt-island.test.ts index 7640c91f37..6ef437d728 100644 --- a/test/nuxt/nuxt-island.test.ts +++ b/test/nuxt/nuxt-island.test.ts @@ -201,4 +201,41 @@ describe('client components', () => { vi.mocked(fetch).mockReset() expectNoConsoleIssue() }) + + + it('should not replace nested client components data-island-uid', async () => { + const componentId = 'Client-12345' + + const stubFetch = vi.fn(() => { + return { + id: '1234', + html: `
hello
`, + 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() + }) }) \ No newline at end of file