-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(effective submission date): Set Initial Submission Date to the n…
…ext valid business day. (#358) * functional * Add tests * remove unneeded info * remove throw * Correct logic * Naming * accommodate github * Update per paul's comments
- Loading branch information
Showing
5 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/packages/shared-utils/tests/seatool-date-helper.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { it, describe, expect } from "vitest"; | ||
import { getNextBusinessDayTimestamp } from "../seatool-date-helper"; | ||
|
||
describe("The getNextBusinessDayTimestamp function", () => { | ||
it("identifies weekenends", () => { | ||
let testDate = new Date(2024, 0, 27, 12, 0, 0); // Saturday, noon, utc | ||
let nextDate = getNextBusinessDayTimestamp(testDate); | ||
expect(nextDate).toEqual(Date.UTC(2024, 0, 29)); // Monday, midnight, utc | ||
}); | ||
|
||
it("identifies holidays", () => { | ||
let testDate = new Date(2024, 0, 15, 12, 0, 0); // MLK Day, a Monday | ||
let nextDate = getNextBusinessDayTimestamp(testDate); | ||
expect(nextDate).toEqual(Date.UTC(2024, 0, 16)); // Tuesday, midnight, utc | ||
}); | ||
|
||
it("identifies submissions after 5pm eastern", () => { | ||
let testDate = new Date(2024, 0, 17, 23, 0, 0); // Wednesday 11pm utc, Wednesday 6pm eastern | ||
let nextDate = getNextBusinessDayTimestamp(testDate); | ||
expect(nextDate).toEqual(Date.UTC(2024, 0, 18)); // Thursday, midnight, utc | ||
}); | ||
|
||
it("identifies submissions before 5pm eastern", () => { | ||
let testDate = new Date(2024, 0, 17, 10, 0, 0); // Wednesday 10am utc, Wednesday 5am eastern | ||
let nextDate = getNextBusinessDayTimestamp(testDate); | ||
expect(nextDate).toEqual(Date.UTC(2024, 0, 17)); // Wednesday, midnight, utc | ||
}); | ||
|
||
it("handles combinations of rule violations", () => { | ||
let testDate = new Date(2024, 0, 12, 23, 0, 0); // Friday 11pm utc, Friday 6pm eastern | ||
let nextDate = getNextBusinessDayTimestamp(testDate); | ||
// Submission is after 5pm, Saturday is a weekend, Sunday is a weekend, and Monday is MLK Day | ||
expect(nextDate).toEqual(Date.UTC(2024, 0, 16)); // Tuesday, midnight utc | ||
}); | ||
|
||
it("identifies valid business days", () => { | ||
let testDate = new Date(2024, 0, 9, 15, 0, 0); // Tuesday 3pm utc, Tuesday 8am eastern | ||
let nextDate = getNextBusinessDayTimestamp(testDate); | ||
expect(nextDate).toEqual(Date.UTC(2024, 0, 9)); // Tuesday, midnight utc | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters