mirror of
https://github.com/zadam/trilium.git
synced 2025-12-03 22:14:24 +01:00
test(dayjs): relocate dayjs tests into commons
This commit is contained in:
parent
af2f6246e8
commit
94d015789d
@ -59,7 +59,7 @@ describe("Script", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("dayjs", () => {
|
||||
describe("dayjs in backend scripts", () => {
|
||||
const scriptNote = note("dayjs", {
|
||||
type: "code",
|
||||
mime: "application/javascript;env=backend",
|
||||
@ -74,7 +74,7 @@ describe("Script", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("dayjs is-same-or-before", () => {
|
||||
it("dayjs is-same-or-before plugin exists", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-01").isSameOrBefore(api.dayjs("2023-10-02"));`);
|
||||
expect(bundle).toBeDefined();
|
||||
@ -82,33 +82,5 @@ describe("Script", () => {
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("dayjs is-same-or-after", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-02").isSameOrAfter(api.dayjs("2023-10-01"));`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("dayjs is-between", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-02").isBetween(api.dayjs("2023-10-01"), api.dayjs("2023-10-03"));`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
// advanced format
|
||||
it("dayjs advanced format", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-01").format("Q");`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).not.toBe("Q");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { LOCALES } from "./i18n.js";
|
||||
import { DAYJS_LOADER } from "./dayjs.js";
|
||||
import { DAYJS_LOADER, dayjs } from "./dayjs.js";
|
||||
|
||||
describe("dayjs", () => {
|
||||
it("all dayjs locales are valid", async () => {
|
||||
@ -10,4 +10,22 @@ describe("dayjs", () => {
|
||||
await dayjsLoader();
|
||||
}
|
||||
});
|
||||
|
||||
describe("Plugins", () => {
|
||||
it("is-same-or-before is available", () => {
|
||||
expect(dayjs("2023-10-01").isSameOrBefore(dayjs("2023-10-02"))).toBe(true);
|
||||
});
|
||||
|
||||
it("is-same-or-after is available", () => {
|
||||
expect(dayjs("2023-10-02").isSameOrAfter(dayjs("2023-10-01"))).toBe(true);
|
||||
});
|
||||
|
||||
it("is-between is available", () => {
|
||||
expect(dayjs("2023-10-02").isBetween(dayjs("2023-10-01"), dayjs("2023-10-03"))).toBe(true);
|
||||
});
|
||||
|
||||
it("advanced format is available", () => {
|
||||
expect(dayjs("2023-10-01").format("Q")).not.toBe("Q");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user