mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
refactor(types): better type definitions
This commit is contained in:
parent
5b9bfac1f8
commit
6f2a0f9ee1
@ -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",
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user