test(import/zip): test silverbullet import

This commit is contained in:
Elian Doran 2025-06-21 01:08:56 +03:00
parent 24c82fa7b6
commit a95dc14d24
No known key found for this signature in database
2 changed files with 21 additions and 0 deletions

View File

@ -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`\