-
-
Notifications
You must be signed in to change notification settings - Fork 497
/
vite-setup.ts
36 lines (28 loc) · 841 Bytes
/
vite-setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import moment, { type Moment } from "moment";
import { vi, expect } from "vitest";
import path from "path";
import { defaultDayFormat } from "./src/constants";
window.moment = moment;
vi.mock("obsidian", () => ({
TFile: vi.fn(),
normalizePath: (p: string) => path.normalize(p),
}));
vi.mock("obsidian-dataview", () => ({
default: vi.fn(),
}));
vi.mock("obsidian-daily-notes-interface", () => ({
default: vi.fn(),
getDateFromPath: vi.fn(() => null),
DEFAULT_DAILY_NOTE_FORMAT: defaultDayFormat,
}));
function areMomentsEqual(a: Moment, b: Moment) {
const isAMomment = moment.isMoment(a);
const isBMomment = moment.isMoment(b);
if (isAMomment && isBMomment) {
return a.isSame(b);
} else if (!isAMomment && !isBMomment) {
return undefined;
}
return false;
}
expect.addEqualityTesters([areMomentsEqual]);