4cddfcf2f3
Backend Tests / Tests (other) (push) Failing after 1s
Backend Tests / Static Checks (push) Failing after 2s
Backend Tests / Tests (internal) (push) Failing after 2s
Backend Tests / Tests (server) (push) Failing after 1s
Backend Tests / Tests (store) (push) Failing after 1s
Build Canary Image / build-frontend (push) Failing after 1s
Frontend Tests / Lint (push) Failing after 1s
Build Canary Image / build-push (linux/amd64) (push) Has been skipped
Build Canary Image / build-push (linux/arm64) (push) Has been skipped
Build Canary Image / merge (push) Has been skipped
Frontend Tests / Build (push) Failing after 1s
Release Please / release-please (push) Failing after 0s
Proto Linter / Lint Protos (push) Failing after 2s
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { EditorState } from "@codemirror/state";
|
|
import { EditorView } from "@codemirror/view";
|
|
import { describe, expect, it } from "vitest";
|
|
import { createController } from "@/components/MemoEditor/Editor/controller";
|
|
|
|
function view(doc = "") {
|
|
return new EditorView({ state: EditorState.create({ doc }) });
|
|
}
|
|
|
|
describe("source editor controller", () => {
|
|
it("round-trips markdown verbatim, including previously-lossy inputs", () => {
|
|
const v = view();
|
|
const c = createController(v, {} as never);
|
|
for (const md of ["", "Title\n===", "1. a\n 1. b\n 1. c", "a b"]) {
|
|
c.setMarkdown(md);
|
|
expect(c.getMarkdown()).toBe(md);
|
|
}
|
|
});
|
|
|
|
it("reports emptiness on whitespace", () => {
|
|
const c = createController(view(" \n "), {} as never);
|
|
expect(c.isEmpty()).toBe(true);
|
|
});
|
|
|
|
it("inserts markdown as its own block", () => {
|
|
const v = view("alpha");
|
|
const c = createController(v, {} as never);
|
|
v.dispatch({ selection: { anchor: 5 } });
|
|
c.insertMarkdown("beta");
|
|
expect(c.getMarkdown()).toBe("alpha\n\nbeta");
|
|
});
|
|
});
|