Skip to content

Commit 270779b

Browse files
committed
test: add snapshots for v3 + v4 wrapped fetch
1 parent c986cc3 commit 270779b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/__snapshots__/useWrappedFetch.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/build.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { exec } from 'tinyexec'
55
import { readPackageJSON } from 'pkg-types'
66
import { dirname, join } from 'pathe'
77
import { findStaticImports } from 'mlly'
8+
import { version as nuxtVersion } from 'nuxt/package.json'
9+
import { satisfies } from 'semver'
810
import { version } from '../package.json'
911

1012
describe('module builder', () => {
@@ -145,7 +147,18 @@ describe('module builder', () => {
145147

146148
it('should generate wrapped composables', async () => {
147149
const componentFile = await readFile(join(distDir, 'runtime/composables/useWrappedFetch.d.ts'), 'utf-8')
148-
await expect(componentFile).toMatchFileSnapshot('__snapshots__/useWrappedFetch.d.ts')
150+
if (satisfies(nuxtVersion, '^3')) {
151+
expect(componentFile).toMatchInlineSnapshot(`
152+
"export declare const useWrappedFetch: () => import("nuxt/app").AsyncData<unknown, import("ofetch").FetchError<any> | null>;
153+
"
154+
`)
155+
}
156+
else {
157+
expect(componentFile).toMatchInlineSnapshot(`
158+
"export declare const useWrappedFetch: () => import("nuxt/app").AsyncData<unknown, import("ofetch").FetchError<any> | undefined>;
159+
"
160+
`)
161+
}
149162
})
150163

151164
it('should handle JSX correctly', async () => {

0 commit comments

Comments
 (0)