refactor(test): remove need for async import

This commit is contained in:
Elian Doran 2025-02-28 19:12:19 +02:00
parent f646e0f724
commit 2531e5617f
No known key found for this signature in database
2 changed files with 5 additions and 7 deletions

View File

@ -1,8 +1,9 @@
import { beforeAll, vi } from "vitest"; import { beforeAll, vi } from "vitest";
import $ from "jquery"; import $ from "jquery";
injectGlobals();
beforeAll(() => { beforeAll(() => {
injectGlobals();
vi.mock("./services/ws.js", mockWebsocket); vi.mock("./services/ws.js", mockWebsocket);
vi.mock("./services/server.js", mockServer); vi.mock("./services/server.js", mockServer);
}); });

View File

@ -1,5 +1,8 @@
import { describe, it } from "vitest"; import { describe, it } from "vitest";
import utils from "../../services/utils.js"; import utils from "../../services/utils.js";
import FNote from "../../entities/fnote.js";
import froca from "../../services/froca.js";
import FAttribute from "../../entities/fattribute.js";
interface NoteDefinition { interface NoteDefinition {
title: string; title: string;
@ -10,10 +13,6 @@ async function buildNotes(notes: NoteDefinition[]) {
const ids = []; const ids = [];
for (const noteDef of notes) { for (const noteDef of notes) {
const FNote = (await import("../../entities/fnote.js")).default;
const FAttribute = (await import("../../entities/fattribute.js")).default;
const froca = (await import("../../services/froca.js")).default;
const fakeNoteId = utils.randomString(6); const fakeNoteId = utils.randomString(6);
const note = new FNote(froca, { const note = new FNote(froca, {
noteId: fakeNoteId, noteId: fakeNoteId,
@ -57,8 +56,6 @@ describe("Building events", () => {
]); ]);
// import CalendarView from "./calendar_view.js"; // import CalendarView from "./calendar_view.js";
const FNote = (await import("../../entities/fnote.js")).default;
const froca = (await import("../../services/froca.js"));
const CalendarView = (await import("./calendar_view.js")).default; const CalendarView = (await import("./calendar_view.js")).default;
const events = await CalendarView.buildEvents(noteIds); const events = await CalendarView.buildEvents(noteIds);
console.log(noteIds, events); console.log(noteIds, events);