From 673b89bfa5cc8ea4739244362bb69d86edefadd3 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 18 Jun 2024 17:24:17 +0100 Subject: [PATCH] test: update tests --- test/basic.test.ts | 16 ++++++++---- test/fixtures/basic/nuxt.config.ts | 1 + .../basic/pages/experimental/decorators.vue | 26 +++++++++++++++++++ .../pages/{ => experimental}/node-compat.vue | 0 .../server/api/experimental/decorators.ts | 14 ++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/basic/pages/experimental/decorators.vue rename test/fixtures/basic/pages/{ => experimental}/node-compat.vue (100%) create mode 100644 test/fixtures/basic/server/api/experimental/decorators.ts diff --git a/test/basic.test.ts b/test/basic.test.ts index 864e48726e..8c131c4363 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -2595,14 +2595,20 @@ describe('teleports', () => { }) }) -describe('Node.js compatibility for client-side', () => { - it('should work', async () => { - const { page } = await renderPage('/node-compat') +describe.only('experimental', () => { + it('decorators support works', async () => { + const html = await $fetch('/experimental/decorators') + expect(html).toContain('decorated-decorated') + expectNoClientErrors('/experimental/decorators') + }) + + it('Node.js compatibility for client-side', async () => { + const { page } = await renderPage('/experimental/node-compat') await page.locator('body').getByText('Nuxt is Awesome!').waitFor() expect(await page.innerHTML('body')).toContain('CWD: [available]') await page.close() - }) -}, 20_000) + }, 30_000) +}) function normaliseIslandResult (result: NuxtIslandResponse) { return { diff --git a/test/fixtures/basic/nuxt.config.ts b/test/fixtures/basic/nuxt.config.ts index 320f957777..a30e84c9b7 100644 --- a/test/fixtures/basic/nuxt.config.ts +++ b/test/fixtures/basic/nuxt.config.ts @@ -242,6 +242,7 @@ export default defineNuxtConfig({ inlineStyles: id => !!id && !id.includes('assets.vue'), }, experimental: { + decorators: true, typedPages: true, polyfillVueUseHead: true, respectNoSSRHeader: true, diff --git a/test/fixtures/basic/pages/experimental/decorators.vue b/test/fixtures/basic/pages/experimental/decorators.vue new file mode 100644 index 0000000000..db7efeaa1f --- /dev/null +++ b/test/fixtures/basic/pages/experimental/decorators.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/test/fixtures/basic/pages/node-compat.vue b/test/fixtures/basic/pages/experimental/node-compat.vue similarity index 100% rename from test/fixtures/basic/pages/node-compat.vue rename to test/fixtures/basic/pages/experimental/node-compat.vue diff --git a/test/fixtures/basic/server/api/experimental/decorators.ts b/test/fixtures/basic/server/api/experimental/decorators.ts new file mode 100644 index 0000000000..e3c8cf8265 --- /dev/null +++ b/test/fixtures/basic/server/api/experimental/decorators.ts @@ -0,0 +1,14 @@ +export default eventHandler((_event) => { + function something(_method: () => unknown) { + return () => 'decorated' + } + + class SomeClass { + @something + public someMethod() { + return 'initial' + } + } + + return new SomeClass().someMethod() +})