Skip to content

Commit

Permalink
split monaco-editor.spec.ts into two files
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Sep 7, 2023
1 parent ed7b21a commit 9a4091c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
34 changes: 34 additions & 0 deletions src/components/main/trace-frame/code-col/__tests__/model.spec.ts
Original file line number Diff line number Diff line change
@@ -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");
});
});
Original file line number Diff line number Diff line change
@@ -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<typeof withSetup>;
Expand Down

0 comments on commit 9a4091c

Please sign in to comment.