From 746e3dcd7dea3f00ac0f67cf7c2d94127c7379a9 Mon Sep 17 00:00:00 2001 From: Teages Date: Thu, 18 Apr 2024 17:00:12 +0800 Subject: [PATCH] chore: add test for outdir of codegen --- test/codegen-outdir.test.ts | 22 ++++++++++++++++++++ test/fixtures/codegen-outdir/app.vue | 5 +++++ test/fixtures/codegen-outdir/nuxt.config.ts | 18 ++++++++++++++++ test/fixtures/codegen-outdir/package.json | 5 +++++ test/fixtures/codegen-outdir/pages/again.vue | 13 ++++++++++++ test/fixtures/codegen-outdir/pages/hello.vue | 22 ++++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100644 test/codegen-outdir.test.ts create mode 100644 test/fixtures/codegen-outdir/app.vue create mode 100644 test/fixtures/codegen-outdir/nuxt.config.ts create mode 100644 test/fixtures/codegen-outdir/package.json create mode 100644 test/fixtures/codegen-outdir/pages/again.vue create mode 100644 test/fixtures/codegen-outdir/pages/hello.vue diff --git a/test/codegen-outdir.test.ts b/test/codegen-outdir.test.ts new file mode 100644 index 0000000..aa951fb --- /dev/null +++ b/test/codegen-outdir.test.ts @@ -0,0 +1,22 @@ +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import { $fetch, setup } from '@nuxt/test-utils/e2e' + +describe('urql', async () => { + await setup({ + rootDir: fileURLToPath(new URL('./fixtures/codegen-outdir', import.meta.url)), + }) + + it('useQuery and useAsyncQuery', async () => { + const html = await $fetch('/hello') + expect(html).toContain('AsyncQuery: hello, one') + expect(html).toContain('Query: hello, two') + expect(html).toContain('AsyncWithGettersQuery: hello, three') + expect(html).toContain('AsyncWithComputedQuery: hello, four') + }) + + it('useMutation', async () => { + const html = await $fetch('/again') + expect(html).toContain('Mutation: hello two from mutation') + }) +}) diff --git a/test/fixtures/codegen-outdir/app.vue b/test/fixtures/codegen-outdir/app.vue new file mode 100644 index 0000000..2b1be09 --- /dev/null +++ b/test/fixtures/codegen-outdir/app.vue @@ -0,0 +1,5 @@ + diff --git a/test/fixtures/codegen-outdir/nuxt.config.ts b/test/fixtures/codegen-outdir/nuxt.config.ts new file mode 100644 index 0000000..9041f94 --- /dev/null +++ b/test/fixtures/codegen-outdir/nuxt.config.ts @@ -0,0 +1,18 @@ +export default defineNuxtConfig({ + modules: ['../../../src/module'], + urqlClient: { + clients: { + hello: { + url: 'https://graphql-test.teages.xyz/graphql-hello', + credentials: 'include', + cookiesFilter: ['locale'], + fetchOptions: { + headers: { + Authorization: 'Bearer 123', + }, + }, + }, + }, + codegen: { outputDir: '.gql' }, + }, +}) diff --git a/test/fixtures/codegen-outdir/package.json b/test/fixtures/codegen-outdir/package.json new file mode 100644 index 0000000..dbdab15 --- /dev/null +++ b/test/fixtures/codegen-outdir/package.json @@ -0,0 +1,5 @@ +{ + "name": "basic", + "type": "module", + "private": true +} diff --git a/test/fixtures/codegen-outdir/pages/again.vue b/test/fixtures/codegen-outdir/pages/again.vue new file mode 100644 index 0000000..15c9a98 --- /dev/null +++ b/test/fixtures/codegen-outdir/pages/again.vue @@ -0,0 +1,13 @@ + + + diff --git a/test/fixtures/codegen-outdir/pages/hello.vue b/test/fixtures/codegen-outdir/pages/hello.vue new file mode 100644 index 0000000..615b87c --- /dev/null +++ b/test/fixtures/codegen-outdir/pages/hello.vue @@ -0,0 +1,22 @@ + + +