Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkiy37 committed Jan 23, 2024
1 parent 453de73 commit b2b2fdf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ function formatToSupportedTimezone(timezoneInput: Timezone): Timezone {
}

/**
* Returns the latest business day of input date month
* Returns the last business day of given date month
*
* param {Date} inputDate
* returns {number}
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/DateUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,28 @@ describe('DateUtils', () => {
describe.only('getLastBusinessDayOfMonth', () => {
const scenarios = [
{
// Last business of May in 2025
// Last business day of May in 2025
inputDate: new Date(2025, 4),
expectedResult: 30,
},
{
// Last business of January in 2024
// Last business day of February in 2024
inputDate: new Date(2024, 2),
expectedResult: 29,
},
{
// Last business day of January in 2024
inputDate: new Date(2024, 0),
expectedResult: 31,
},
{
// Last business of September in 2023
// Last business day of September in 2023
inputDate: new Date(2023, 8),
expectedResult: 29,
},
];

test.each(scenarios)('returns a last business day of an input date', ({inputDate, expectedResult}) => {
test.each(scenarios)('returns a last business day based on the input date', ({inputDate, expectedResult}) => {
const lastBusinessDay = DateUtils.getLastBusinessDayOfMonth(inputDate);

expect(lastBusinessDay).toEqual(expectedResult);
Expand Down

0 comments on commit b2b2fdf

Please sign in to comment.