refactor(types): better type definitions

This commit is contained in:
Elian Doran 2025-02-28 19:44:32 +02:00
parent 5b9bfac1f8
commit 6f2a0f9ee1
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View File

@ -3,9 +3,11 @@ import FNote from "../entities/fnote.js";
import froca from "../services/froca.js";
import FAttribute from "../entities/fattribute.js";
interface NoteDefinition {
type AttributeDefinitions = { [key in `#${string}`]: string; }
interface NoteDefinition extends AttributeDefinitions {
id?: string | undefined;
title: string;
[key: string]: string;
}
/**
@ -27,9 +29,8 @@ export function buildNotes(notes: NoteDefinition[]) {
const ids = [];
for (const noteDef of notes) {
const fakeNoteId = utils.randomString(6);
const note = new FNote(froca, {
noteId: fakeNoteId,
noteId: noteDef.id ?? utils.randomString(12),
title: noteDef.title,
type: "text",
mime: "text/html",

View File

@ -18,7 +18,7 @@ describe("Building events", () => {
it("ignores notes with only end date", async () => {
const noteIds = buildNotes([
{ title: "Note 1", "#endDate": "2025-05-05" },
{ title: "Note 2", "#endDateDate": "2025-05-07" },
{ title: "Note 2", "#endDateDate": "2025-05-07" }
]);
const events = await CalendarView.buildEvents(noteIds);