Skip to content

Commit

Permalink
Fix weekly note unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcain committed Jan 17, 2021
1 parent 0984cff commit d8bd5a4
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/io/__tests__/weeklyNotes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,31 @@ describe("getDayOfWeekNumericalValue", () => {
});

describe("start week on Sunday", () => {
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(<any>moment.localeData())._week.dow = 0;
});

test("returns 0 for sunday", () => {
getDefaultSettings({
weekStart: "sunday",
});
expect(weeklyNote.getDayOfWeekNumericalValue("sunday")).toEqual(0);
});

test("returns 1 for monday", () => {
getDefaultSettings({
weekStart: "sunday",
});
expect(weeklyNote.getDayOfWeekNumericalValue("monday")).toEqual(1);
});
});

describe("start week on Monday", () => {
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(<any>moment.localeData())._week.dow = 1;
});

test("returns 0 for sunday", () => {
getDefaultSettings({
weekStart: "monday",
});
expect(weeklyNote.getDayOfWeekNumericalValue("sunday")).toEqual(6);
});

test("returns 1 for monday", () => {
getDefaultSettings({
weekStart: "monday",
});
expect(weeklyNote.getDayOfWeekNumericalValue("monday")).toEqual(0);
});
});
Expand Down Expand Up @@ -85,6 +83,11 @@ describe("createWeeklyNote", () => {
});

describe("start week on Sunday", () => {
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(<any>moment.localeData())._week.dow = 0;
});

test("replaces {{sunday}} and {{monday}} in weekly note", async () => {
(getTemplateContents as jest.MockedFunction<
typeof getTemplateContents
Expand All @@ -105,6 +108,11 @@ describe("createWeeklyNote", () => {
});

describe("start week on Monday", () => {
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(<any>moment.localeData())._week.dow = 1;
});

test("replaces {{sunday}} and {{monday}} in weekly note", async () => {
(getTemplateContents as jest.MockedFunction<
typeof getTemplateContents
Expand Down

0 comments on commit d8bd5a4

Please sign in to comment.