Skip to content

Commit

Permalink
Make tests locale independent (#2592) (#2593)
Browse files Browse the repository at this point in the history
* Make tests locale independent (#2592)

* use newUTC for consistency

---------

Co-authored-by: Kræn Hansen <kraen.hansen@mongodb.com>
  • Loading branch information
TheSonOfThomp and kraenhansen authored Dec 13, 2024
1 parent d4b4d51 commit 24c828d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { Month } from '../constants';
import { newUTC } from '../newUTC';

import { getDaysInUTCMonth } from '.';

describe('packages/date-utils/getDaysInUTCMonth', () => {
test('returns the number of days in the month', () => {
const result = getDaysInUTCMonth(new Date(2100, 1 /* Feb */, 11));
const result = getDaysInUTCMonth(newUTC(2100, Month.February, 11));
expect(result).toEqual(28);
});

test('when given the 1st of the month', () => {
const result = getDaysInUTCMonth(new Date(2100, 1 /* Feb */, 1));
const result = getDaysInUTCMonth(newUTC(2100, Month.February, 1));
expect(result).toEqual(28);
});

test('when given the last of the month', () => {
const result = getDaysInUTCMonth(new Date(2100, 1 /* Feb */, 28));
const result = getDaysInUTCMonth(newUTC(2100, Month.February, 28));
expect(result).toEqual(28);
});

test('when given February of a leap year', () => {
const result = getDaysInUTCMonth(new Date(2000, 1 /* Feb */, 1));
const result = getDaysInUTCMonth(newUTC(2000, Month.February, 1));
expect(result).toEqual(29);
});

Expand Down

0 comments on commit 24c828d

Please sign in to comment.