-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for customParseFormat.utils.js
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import MockDate from 'mockdate' | ||
import { daysInMonth } from '../../src/plugin/customParseFormat/utils' | ||
|
||
beforeEach(() => { | ||
MockDate.set(new Date()) | ||
}) | ||
|
||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('Days in Month for months with constant length', () => { | ||
expect(daysInMonth(2022, 5)).toBe(31) | ||
expect(daysInMonth(2013, 9)).toBe(30) | ||
}) | ||
|
||
it('Days in Month for february', () => { | ||
expect(daysInMonth(2003, 2)).toBe(28) | ||
expect(daysInMonth(2100, 2)).toBe(28) | ||
expect(daysInMonth(2000, 2)).toBe(29) | ||
expect(daysInMonth(2004, 2)).toBe(29) | ||
}) | ||
|
||
it('Days in Month with wrong parameter types', () => { | ||
expect(daysInMonth(Number.NaN, 5)).toBeNaN() | ||
expect(daysInMonth(2013, Number.NaN)).toBeNaN() | ||
}) |