Skip to content

Commit

Permalink
test: update mock-transform snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 2, 2023
1 parent d32c049 commit 330b7a1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/unit/mock-transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ describe('mocking', () => {
return () => 'mocked'
})
`)).toMatchInlineSnapshot(`
"import {vi} from \\"vitest\\";
"import {vi} from "vitest";
vi.hoisted(() => {
if(!globalThis.__NUXT_VITEST_MOCKS){
vi.stubGlobal(\\"__NUXT_VITEST_MOCKS\\", {})
vi.stubGlobal("__NUXT_VITEST_MOCKS", {})
}
});
vi.mock(\\"bob\\", async (importOriginal) => {
vi.mock("bob", async (importOriginal) => {
const mocks = globalThis.__NUXT_VITEST_MOCKS
if (!mocks[\\"bob\\"]) {
mocks[\\"bob\\"] = { ...await importOriginal(\\"bob\\") }
if (!mocks["bob"]) {
mocks["bob"] = { ...await importOriginal("bob") }
}
mocks[\\"bob\\"][\\"useSomeExport\\"] = await (() => {
mocks["bob"]["useSomeExport"] = await (() => {
return () => 'mocked'
})();
return mocks[\\"bob\\"]
return mocks["bob"]
});
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import \\"bob\\";"
import "bob";"
`)
})
it('should not add `vi` import if it already exists', async () => {
Expand Down Expand Up @@ -100,13 +100,13 @@ describe('mocking', () => {
import { mockComponent } from '@nuxt/test-utils/runtime-utils'
mockComponent('MyComponent', () => import('./MockComponent.vue'))
`)).toMatchInlineSnapshot(`
"import {vi} from \\"vitest\\";
"import {vi} from "vitest";
vi.hoisted(() => {
if(!globalThis.__NUXT_VITEST_MOCKS){
vi.stubGlobal(\\"__NUXT_VITEST_MOCKS\\", {})
vi.stubGlobal("__NUXT_VITEST_MOCKS", {})
}
});
vi.mock(\\"MyComponent\\", async () => {
vi.mock("MyComponent", async () => {
const factory = (() => import('./MockComponent.vue'));
const result = typeof factory === 'function' ? await factory() : await factory
return 'default' in result ? result : { default: result }
Expand Down

0 comments on commit 330b7a1

Please sign in to comment.