mirror of https://github.com/TriliumNext/Notes
chore(test): add test for content_renderer#renderCode
parent
f12057f799
commit
a05e174640
@ -0,0 +1,33 @@
|
|||||||
|
import { renderCode, type Result } from "./content_renderer.js";
|
||||||
|
|
||||||
|
describe("content_renderer", () => {
|
||||||
|
describe("renderCode", () => {
|
||||||
|
it("identifies empty content", () => {
|
||||||
|
const emptyResult: Result = {
|
||||||
|
header: "",
|
||||||
|
content: " "
|
||||||
|
};
|
||||||
|
renderCode(emptyResult);
|
||||||
|
expect(emptyResult.isEmpty).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("identifies unsupported content type", () => {
|
||||||
|
const emptyResult: Result = {
|
||||||
|
header: "",
|
||||||
|
content: Buffer.from("Hello world")
|
||||||
|
};
|
||||||
|
renderCode(emptyResult);
|
||||||
|
expect(emptyResult.isEmpty).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("wraps code in <pre>", () => {
|
||||||
|
const result: Result = {
|
||||||
|
header: "",
|
||||||
|
content: "\tHello\nworld"
|
||||||
|
};
|
||||||
|
renderCode(result);
|
||||||
|
expect(result.isEmpty).toBeFalsy();
|
||||||
|
expect(result.content).toBe("<pre>\tHello\nworld</pre>");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue