mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
code-review (xhigh) pass: - lazy-load useGamepad so vitest.setup.ts no longer caches it ahead of useGamepad/index.test.ts's vue-router mock (5 failures in the full suite) - drop flush: "sync" on the re-pin watcher, which ran between setModality's ref write and DOM write and let a listener's data-input win - stop the re-pin watcher on HMR - test that a pin survives the live listeners, and assert data-input in play() Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
29 lines
1006 B
TypeScript
29 lines
1006 B
TypeScript
import type { StoryContext } from "@storybook/vue3-vite";
|
|
import { mount } from "@vue/test-utils";
|
|
import { expect, it, vi } from "vitest";
|
|
import { defineComponent, nextTick, reactive } from "vue";
|
|
|
|
it("keeps a pinned mode once the live listeners are installed", async () => {
|
|
// vitest.setup.ts already loaded the decorator, so load a fresh copy with
|
|
// its own modality singleton.
|
|
vi.resetModules();
|
|
const { useInputModality } =
|
|
await import("@/v2/composables/useInputModality");
|
|
const { withInputModality } = await import("../.storybook/withInputModality");
|
|
useInputModality().install();
|
|
|
|
const globals = reactive({ input: "key" });
|
|
const story = defineComponent({ render: () => null });
|
|
mount(
|
|
withInputModality(
|
|
story as unknown as Parameters<typeof withInputModality>[0],
|
|
{ globals } as unknown as StoryContext,
|
|
),
|
|
);
|
|
|
|
window.dispatchEvent(new Event("touchstart"));
|
|
await nextTick();
|
|
|
|
expect(document.documentElement.dataset.input).toBe("key");
|
|
});
|