mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
test(import/zip): test silverbullet import
This commit is contained in:
parent
24c82fa7b6
commit
a95dc14d24
BIN
apps/server/src/services/import/samples/silverbullet.zip
Normal file
BIN
apps/server/src/services/import/samples/silverbullet.zip
Normal file
Binary file not shown.
@ -60,8 +60,29 @@ describe("processNoteContent", () => {
|
|||||||
const htmlNote = rootNote.children.find((ch) => ch.title === "IREN Reports Q2 FY25 Results");
|
const htmlNote = rootNote.children.find((ch) => ch.title === "IREN Reports Q2 FY25 Results");
|
||||||
expect(htmlNote?.getContent().toString().substring(0, 4)).toEqual("<div");
|
expect(htmlNote?.getContent().toString().substring(0, 4)).toEqual("<div");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("can import from Silverbullet", async () => {
|
||||||
|
const { importedNote } = await testImport("silverbullet.zip");
|
||||||
|
const bananaNote = getNoteByTitlePath(importedNote, "assets", "banana.jpeg");
|
||||||
|
const mondayNote = getNoteByTitlePath(importedNote, "journal", "monday");
|
||||||
|
const shopNote = getNoteByTitlePath(importedNote, "other", "shop");
|
||||||
|
const content = mondayNote?.getContent();
|
||||||
|
expect(content).toContain(`<a class="reference-link" href="#root/${shopNote.noteId}`);
|
||||||
|
expect(content).toContain(`<img src="api/images/${bananaNote!.noteId}/banana.jpeg`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getNoteByTitlePath(parentNote: BNote, ...titlePath: string[]) {
|
||||||
|
let cursor = parentNote;
|
||||||
|
for (const title of titlePath) {
|
||||||
|
const childNote = cursor.getChildNotes().find(n => n.title === title);
|
||||||
|
expect(childNote).toBeTruthy();
|
||||||
|
cursor = childNote!;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
describe("removeTriliumTags", () => {
|
describe("removeTriliumTags", () => {
|
||||||
it("removes <h1> tags from HTML", () => {
|
it("removes <h1> tags from HTML", () => {
|
||||||
const output = removeTriliumTags(trimIndentation`\
|
const output = removeTriliumTags(trimIndentation`\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user