|
1 | | -// // @vitest-environment nuxt |
2 | | - |
3 | | -// import { describe, expect, test, vi } from "vitest" |
4 | | -// import { flushPromises } from "@vue/test-utils" |
5 | | -// import { mountSuspended } from "@nuxt/test-utils/runtime" |
6 | | - |
7 | | -// import { createVuetify } from "vuetify" |
8 | | -// import * as components from "vuetify/components" |
9 | | -// import * as directives from "vuetify/directives" |
10 | | - |
11 | | -// import Launcher from "@/components/Launcher.vue" |
12 | | - |
13 | | -// const vuetify = createVuetify({ |
14 | | -// components, |
15 | | -// directives, |
16 | | -// }) |
17 | | - |
18 | | -// const infra_store = use_infra_store() |
19 | | - |
20 | | -// global.ResizeObserver = require("resize-observer-polyfill") |
21 | | - |
22 | | -// describe("Launcher.vue", async () => { |
23 | | -// test(`Mount`, async () => { |
24 | | -// const spy_infra_store = vi.spyOn(infra_store, "create_backend") |
25 | | -// const wrapper = await mountSuspended(Launcher, { |
26 | | -// global: { |
27 | | -// plugins: [vuetify], |
28 | | -// }, |
29 | | -// }) |
30 | | -// expect(wrapper.exists()).toBe(true) |
31 | | -// await infra_store.$patch({ is_captcha_validated: true }) |
32 | | -// flushPromises() |
33 | | -// expect(spy_infra_store).toHaveBeenCalled() |
34 | | -// }) |
35 | | -// }) |
36 | | -describe("Fake", async () => { |
37 | | - test(`Fake`, async () => {}) |
| 1 | +// @vitest-environment nuxt |
| 2 | + |
| 3 | +import { describe, expect, test, vi } from "vitest" |
| 4 | +import { flushPromises } from "@vue/test-utils" |
| 5 | +import { mountSuspended } from "@nuxt/test-utils/runtime" |
| 6 | + |
| 7 | +import { createVuetify } from "vuetify" |
| 8 | +import * as components from "vuetify/components" |
| 9 | +import * as directives from "vuetify/directives" |
| 10 | + |
| 11 | +import Launcher from "@/components/Launcher.vue" |
| 12 | + |
| 13 | +const vuetify = createVuetify({ |
| 14 | + components, |
| 15 | + directives, |
| 16 | +}) |
| 17 | + |
| 18 | +const infra_store = use_infra_store() |
| 19 | + |
| 20 | +// Mock navigator.locks API |
| 21 | +const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => { |
| 22 | + return callback({ name }) |
| 23 | +}) |
| 24 | + |
| 25 | +vi.stubGlobal("navigator", { |
| 26 | + ...navigator, |
| 27 | + locks: { |
| 28 | + request: mockLockRequest, |
| 29 | + }, |
| 30 | +}) |
| 31 | + |
| 32 | +global.ResizeObserver = require("resize-observer-polyfill") |
| 33 | + |
| 34 | +describe("Launcher.vue", async () => { |
| 35 | + test(`Mount`, async () => { |
| 36 | + const spy_infra_store = vi.spyOn(infra_store, "create_backend") |
| 37 | + const wrapper = await mountSuspended(Launcher, { |
| 38 | + global: { |
| 39 | + plugins: [vuetify], |
| 40 | + }, |
| 41 | + }) |
| 42 | + expect(wrapper.exists()).toBe(true) |
| 43 | + await infra_store.$patch({ is_captcha_validated: true }) |
| 44 | + flushPromises() |
| 45 | + expect(spy_infra_store).toHaveBeenCalled() |
| 46 | + }) |
38 | 47 | }) |
0 commit comments