Skip to content

Commit

Permalink
🐛 fixed bug with dates and mute windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohland committed Nov 27, 2023
1 parent 8d31f76 commit 4e01be4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "barky",
"version": "1.1.5",
"version": "1.1.6",
"description": "A simple cloud services watchdog with digest notification support & no external dependencies",
"homepage": "https://github.com/Rohland/barky#readme",
"main": "dist/cli.js",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export function isToday(date: string, on?: Date): boolean {
return inputDate.getTime() === today.getTime();
}

export function dayOfWeek(date: Date): number {
const day = date.toLocaleString("en-US", {
export function dayOfWeek(date?: Date): number {
const day = (date || new Date()).toLocaleString("en-US", {
timeZone: timeZone,
weekday: 'short'
});
Expand Down
16 changes: 16 additions & 0 deletions src/models/mute-window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ describe("mute-windows", () => {
});
});
});
describe("can be called with null date", () => {
it("should infer now", async () => {
// arrange
const config = {
time: "00:00-24:00",
date: new Date().toISOString().split('T')[0],
days: ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] };
const muteWindow = new MuteWindow(config);

// act
const isMuted = muteWindow.isMutedAt();

// assert
expect(isMuted).toEqual(true);
});
});
});
describe("with match", () => {
describe.each([
Expand Down

0 comments on commit 4e01be4

Please sign in to comment.