mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
test(server): tests failing due to CLS and lack of content
This commit is contained in:
parent
8ac0425ca5
commit
b2fcf5fa6c
@ -1,4 +1,5 @@
|
||||
import { BNote } from "../../services/backend_script_entrypoint";
|
||||
import cls from "../../services/cls";
|
||||
import { buildNote } from "../../test/becca_easy_mocking";
|
||||
import { processContent } from "./clipper";
|
||||
|
||||
@ -6,7 +7,9 @@ let note!: BNote;
|
||||
|
||||
describe("processContent", () => {
|
||||
beforeAll(() => {
|
||||
note = buildNote({});
|
||||
note = buildNote({
|
||||
content: "Hi there"
|
||||
});
|
||||
note.saveAttachment = () => {};
|
||||
vi.mock("../../services/image.js", () => ({
|
||||
default: {
|
||||
@ -21,29 +24,29 @@ describe("processContent", () => {
|
||||
});
|
||||
|
||||
it("processes basic note", () => {
|
||||
const processed = processContent([], note, "<p>Hello world.</p>");
|
||||
const processed = cls.init(() => processContent([], note, "<p>Hello world.</p>"));
|
||||
expect(processed).toStrictEqual("<p>Hello world.</p>")
|
||||
});
|
||||
|
||||
it("processes plain text", () => {
|
||||
const processed = processContent([], note, "Hello world.");
|
||||
const processed = cls.init(() => processContent([], note, "Hello world."));
|
||||
expect(processed).toStrictEqual("<p>Hello world.</p>")
|
||||
});
|
||||
|
||||
it("replaces images", () => {
|
||||
const processed = processContent(
|
||||
const processed = cls.init(() => processContent(
|
||||
[{"imageId":"OKZxZA3MonZJkwFcEhId","src":"inline.png","dataUrl":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAF0lEQVQoU2P8DwQMBADjqKLRIGAgKggAzHs/0SoYCGwAAAAASUVORK5CYII="}],
|
||||
note, `<img src="OKZxZA3MonZJkwFcEhId">`
|
||||
);
|
||||
));
|
||||
expect(processed).toStrictEqual(`<img src="api/attachments/foo/image/encodedTitle" >`);
|
||||
});
|
||||
|
||||
it("skips over non-data images", () => {
|
||||
for (const url of [ "foo", "" ]) {
|
||||
const processed = processContent(
|
||||
const processed = cls.init(() => processContent(
|
||||
[{"imageId":"OKZxZA3MonZJkwFcEhId","src":"inline.png","dataUrl": url}],
|
||||
note, `<img src="OKZxZA3MonZJkwFcEhId">`
|
||||
);
|
||||
));
|
||||
expect(processed).toStrictEqual(`<img src="OKZxZA3MonZJkwFcEhId" >`);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user