import { beforeAll, describe, expect, it } from "vitest"; import FNote from "../../../entities/fnote"; import { buildNote } from "../../../test/easy-froca"; import { buildPresentationModel, PresentationModel } from "./model"; let presentationNote!: FNote; let data!: PresentationModel; describe("Presentation model", () => { beforeAll(async () => { presentationNote = buildNote({ title: "Presentation", id: "presentation", "#viewType": "presentation", "children": [ { id: "slide1", title: "First slide", children: [ { id: "slide2", title: "First-sub", content: `

Go to Other note.

` } ] }, { title: "Second slide", id: "slide3", content: `

Go to First slide.

`, children: [ { id: "slide4", title: "Second-sub", content: `

Go to First-sub.

`, } ] } ] }); buildNote({ id: "other", title: "Other note" }); data = await buildPresentationModel(presentationNote); }); it("it correctly maps horizontal and vertical slides", () => { expect(data).toMatchObject({ slides: [ { noteId: "slide1", verticalSlides: [ { noteId: "slide2" } ] }, { noteId: "slide3", verticalSlides: [ { noteId: "slide4" } ] } ] }); }); it("empty slides don't render children", () => { expect(data.slides[0].content.__html).toStrictEqual(""); }); it("rewrites links to other slides", () => { expect(data.slides[1].content.__html).toStrictEqual(`

Go to First slide.

`); expect(data.slides[1].verticalSlides![0].content.__html).toStrictEqual(`

Go to First-sub.

`); }); it("rewrites links even if they are not part of the slideshow", () => { expect(data.slides[0].verticalSlides![0].content.__html).toStrictEqual(`

Go to Other note.

`); }); });