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