From b4af371f740414ca8c7a9d4a9c6bd88c44f5803a Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Sat, 13 Jul 2024 22:14:23 +0900 Subject: [PATCH] stash --- .../store/__snapshots__/command.spec.ts.snap | 41 +++++++++++++++++++ tests/unit/store/command.spec.ts | 20 +++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/unit/store/__snapshots__/command.spec.ts.snap create mode 100644 tests/unit/store/command.spec.ts diff --git a/tests/unit/store/__snapshots__/command.spec.ts.snap b/tests/unit/store/__snapshots__/command.spec.ts.snap new file mode 100644 index 0000000000..612a4d0f5a --- /dev/null +++ b/tests/unit/store/__snapshots__/command.spec.ts.snap @@ -0,0 +1,41 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`コマンド実行で履歴が作られる 1`] = ` +{ + "audioKeys": [ + "00000000-0000-0000-0000-000000000000", + ], + "redoCommands": { + "song": [], + "talk": [], + }, + "undoCommands": { + "song": [], + "talk": [ + { + "redoPatches": [ + { + "op": "replace", + "path": [ + "audioKeys", + ], + "value": [ + "00000000-0000-0000-0000-000000000000", + ], + }, + ], + "undoPatches": [ + { + "op": "replace", + "path": [ + "audioKeys", + ], + "value": [], + }, + ], + "unixMillisec": 1720797286952, + }, + ], + }, +} +`; diff --git a/tests/unit/store/command.spec.ts b/tests/unit/store/command.spec.ts new file mode 100644 index 0000000000..0b69b81eae --- /dev/null +++ b/tests/unit/store/command.spec.ts @@ -0,0 +1,20 @@ +import { toRaw } from "vue"; +import { store } from "@/store"; +import { AudioKey } from "@/type/preload"; + +const initialState = structuredClone(toRaw(store.state)); +beforeEach(() => { + store.replaceState(initialState); +}); + +test("コマンド実行で履歴が作られる", async () => { + await store.dispatch("COMMAND_SET_AUDIO_KEYS", { + audioKeys: [AudioKey("00000000-0000-0000-0000-000000000000")], + }); + + // npm run test-watch:unit -- "tests\unit\store\command.spec.ts" + // millisecをrandomUuidにし、かつrandomUuidをmockにする + + const { audioKeys, redoCommands, undoCommands } = store.state; + expect({ audioKeys, redoCommands, undoCommands }).toMatchSnapshot(); +});