diff --git a/src/components/main/trace-frame/code-col/__tests__/model.spec.ts b/src/components/main/trace-frame/code-col/__tests__/model.spec.ts new file mode 100644 index 0000000..df12d7c --- /dev/null +++ b/src/components/main/trace-frame/code-col/__tests__/model.spec.ts @@ -0,0 +1,34 @@ +import { describe, it, expect } from "vitest"; +import { ref, nextTick } from "vue"; + +import { useModel } from "../monaco-editor"; + +describe("useModel()", () => { + it("call without arguments", () => { + const { model, source } = useModel(); + expect(source.value).toBe(""); + expect(model.getValue()).toBe(""); + }); + + it("call with string source", () => { + const source = "# Hello, world!"; + const { model } = useModel(source); + expect(model.getValue()).toBe("# Hello, world!"); + }); + + it("call with ref source", () => { + const source = ref("# Hello, world!"); + const { model, source: sourceReturned } = useModel(source); + expect(sourceReturned === source).toBe(true); + expect(model.getValue()).toBe("# Hello, world!"); + }); + + it("source is reactive", async () => { + const source = ref("# Hello, world!"); + const { model } = useModel(source); + expect(model.getValue()).toBe("# Hello, world!"); + source.value = "# New source"; + await nextTick(); + expect(model.getValue()).toBe("# New source"); + }); +}); diff --git a/src/components/main/trace-frame/code-col/__tests__/monaco-editor.spec.ts b/src/components/main/trace-frame/code-col/__tests__/monaco-editor.spec.ts index 82bd7e8..d7ba2fd 100644 --- a/src/components/main/trace-frame/code-col/__tests__/monaco-editor.spec.ts +++ b/src/components/main/trace-frame/code-col/__tests__/monaco-editor.spec.ts @@ -1,41 +1,9 @@ -import { describe, it, expect, beforeEach, afterEach } from "vitest"; -import { ref, nextTick } from "vue"; +import { describe, it, expect, afterEach } from "vitest"; +import { ref } from "vue"; import { withSetup } from "@/tests/test-utils"; -import { useModel, useMonacoEditor } from "../monaco-editor"; - -describe("useModel()", () => { - - it("call without arguments", () => { - const { model, source } = useModel(); - expect(source.value).toBe(""); - expect(model.getValue()).toBe(""); - }); - - it("call with string source", () => { - const source = "# Hello, world!"; - const { model } = useModel(source); - expect(model.getValue()).toBe("# Hello, world!"); - }); - - it("call with ref source", () => { - const source = ref("# Hello, world!"); - const { model, source: sourceReturned } = useModel(source); - expect(sourceReturned === source).toBe(true); - expect(model.getValue()).toBe("# Hello, world!"); - }); - - it("source is reactive", async () => { - const source = ref("# Hello, world!"); - const { model } = useModel(source); - expect(model.getValue()).toBe("# Hello, world!"); - source.value = "# New source"; - await nextTick(); - expect(model.getValue()).toBe("# New source"); - }); - -}); +import { useMonacoEditor } from "../monaco-editor"; describe("useMonacoEditor", () => { let app!: ReturnType;