mirror of
https://github.com/zadam/trilium.git
synced 2025-12-05 06:54:23 +01:00
edited notes: better names in tests
This commit is contained in:
parent
e18fc4c70d
commit
366a8bd841
@ -17,10 +17,10 @@ const expectedMonthMinus2 = "2024-11";
|
|||||||
const expectedYear = "2025";
|
const expectedYear = "2025";
|
||||||
const expectedYearMinus1 = "2024";
|
const expectedYearMinus1 = "2024";
|
||||||
|
|
||||||
function runTest(dateStrToResolve: string, expectedDate: string) {
|
function keywordResolvesToDate(dateStrOrKeyword: string, expectedDate: string) {
|
||||||
cls.init(() => {
|
cls.init(() => {
|
||||||
cls.set("localNowDateTime", clientDate);
|
cls.set("localNowDateTime", clientDate);
|
||||||
const dateFilter = dateNoteLabelKeywordToDateFilter(dateStrToResolve);
|
const dateFilter = dateNoteLabelKeywordToDateFilter(dateStrOrKeyword);
|
||||||
expect(dateFilter.date).toBe(expectedDate);
|
expect(dateFilter.date).toBe(expectedDate);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -39,51 +39,51 @@ describe("edited-notes::dateNoteLabelKeywordToDateFilter", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'TODAY' to today's date", () => {
|
it("resolves 'TODAY' to today's date", () => {
|
||||||
runTest("TODAY", expectedToday);
|
keywordResolvesToDate("TODAY", expectedToday);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'MONTH' to current month", () => {
|
it("resolves 'MONTH' to current month", () => {
|
||||||
runTest("MONTH", expectedMonth);
|
keywordResolvesToDate("MONTH", expectedMonth);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'YEAR' to current year", () => {
|
it("resolves 'YEAR' to current year", () => {
|
||||||
runTest("YEAR", expectedYear);
|
keywordResolvesToDate("YEAR", expectedYear);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'TODAY-1' to yesterday's date", () => {
|
it("resolves 'TODAY-1' to yesterday's date", () => {
|
||||||
runTest("TODAY-1", expectedTodayMinus1);
|
keywordResolvesToDate("TODAY-1", expectedTodayMinus1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'MONTH-2' to 2 months ago", () => {
|
it("resolves 'MONTH-2' to 2 months ago", () => {
|
||||||
runTest("MONTH-2", expectedMonthMinus2);
|
keywordResolvesToDate("MONTH-2", expectedMonthMinus2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'YEAR-1' to last year", () => {
|
it("resolves 'YEAR-1' to last year", () => {
|
||||||
runTest("YEAR-1", expectedYearMinus1);
|
keywordResolvesToDate("YEAR-1", expectedYearMinus1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns original string for day", () => {
|
it("returns original string for day", () => {
|
||||||
runTest("2020-12-31", "2020-12-31");
|
keywordResolvesToDate("2020-12-31", "2020-12-31");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns original string for month", () => {
|
it("returns original string for month", () => {
|
||||||
runTest("2020-12", "2020-12");
|
keywordResolvesToDate("2020-12", "2020-12");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns original string for year", () => {
|
it("returns original string for year", () => {
|
||||||
runTest("2020", "2020");
|
keywordResolvesToDate("2020", "2020");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns original string for unrecognized keyword", () => {
|
it("returns original string for unrecognized keyword", () => {
|
||||||
runTest("FOO", "FOO");
|
keywordResolvesToDate("FOO", "FOO");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns original string for partially recognized keyword", () => {
|
it("returns original string for partially recognized keyword", () => {
|
||||||
runTest("TODAY-", "TODAY-");
|
keywordResolvesToDate("TODAY-", "TODAY-");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("resolves 'today' (lowercase) to today's date", () => {
|
it("resolves 'today' (lowercase) to today's date", () => {
|
||||||
runTest("today", expectedToday);
|
keywordResolvesToDate("today", expectedToday);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user