From 41fcb19550ffa340b8fe496a86dc6fedca83f032 Mon Sep 17 00:00:00 2001 From: julien huang Date: Sun, 20 Aug 2023 22:59:34 +0200 Subject: [PATCH] test: set back old tests for webpack with isWebpack --- test/basic.test.ts | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/test/basic.test.ts b/test/basic.test.ts index 8a5495ebb6..3c92c04ac3 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -1452,7 +1452,11 @@ describe('server components/islands', () => { const text = (await page.innerText('pre')).replace(/nuxt-ssr-client="([^"]*)"/g, (_, content) => `nuxt-ssr-client="${content.split('-')[0]}"`) - expect(text).toMatchInlineSnapshot('" End page
This is a .server (20ms) async component that was very long ...
42
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
This is a .server (20ms) async component that was very long ...
42
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
"') + if (isWebpack) { + expect(text).toMatchInlineSnapshot('" End page
This is a .server (20ms) async component that was very long ...
42
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
Sugar Counter 12 x 1 = 12
This is a .server (20ms) async component that was very long ...
42
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
Sugar Counter 12 x 1 = 12
"') + } else { + expect(text).toMatchInlineSnapshot('" End page
This is a .server (20ms) async component that was very long ...
42
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
This is a .server (20ms) async component that was very long ...
42
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
"') + } expect(text).toContain('async component that was very long') // Wait for all pending micro ticks to be cleared @@ -1720,7 +1724,22 @@ describe('component islands', () => { result.teleports = {} result.chunks = {} result.html = result.html.replace(/ nuxt-ssr-client="([^"]*)"/g, (_, content) => `'nuxt-ssr-client="${content.split('-')[0]}"`) - expect(result).toMatchInlineSnapshot(` + if (isWebpack) { + expect(result).toMatchInlineSnapshot(` + { + "chunks": {}, + "head": { + "link": [], + "style": [], + }, + "html": "
This is a .server (20ms) async component that was very long ...
2
Sugar Counter 12 x 1 = 12
The component bellow is not a slot but declared as interactive
Sugar Counter 12 x 1 = 12
", + "props": {}, + "state": {}, + "teleports": {}, + } + `) + } else { + expect(result).toMatchInlineSnapshot(` { "chunks": {}, "head": { @@ -1733,21 +1752,21 @@ describe('component islands', () => { "teleports": {}, } `) - - const propsEntries = Object.entries(props) - const teleportsEntries = Object.entries(teleports) - const chunksEntries = Object.entries(chunks) - expect(propsEntries).toHaveLength(1) - expect(teleportsEntries).toHaveLength(1) - expect(propsEntries[0][0].startsWith('SugarCounter-')).toBeTruthy() - expect(teleportsEntries[0][0].startsWith('SugarCounter-')).toBeTruthy() - expect(chunksEntries[0][0]).toBe('SugarCounter') - expect(propsEntries[0][1]).toMatchInlineSnapshot(` + const propsEntries = Object.entries(props) + const teleportsEntries = Object.entries(teleports) + const chunksEntries = Object.entries(chunks) + expect(propsEntries).toHaveLength(1) + expect(teleportsEntries).toHaveLength(1) + expect(propsEntries[0][0].startsWith('SugarCounter-')).toBeTruthy() + expect(teleportsEntries[0][0].startsWith('SugarCounter-')).toBeTruthy() + expect(chunksEntries[0][0]).toBe('SugarCounter') + expect(propsEntries[0][1]).toMatchInlineSnapshot(` { "multiplier": 1, } `) - expect(teleportsEntries[0][1]).toMatchInlineSnapshot('"
Sugar Counter 12 x 1 = 12
"') + expect(teleportsEntries[0][1]).toMatchInlineSnapshot('"
Sugar Counter 12 x 1 = 12
"') + } }) it('renders pure components', async () => {