Skip to content

Commit

Permalink
test: add tests for customParseFormat.utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
BePo65 committed Jun 6, 2022
1 parent 2c1059f commit 2f49389
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/plugin/customParseFormat.utils.test.js
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()
})

0 comments on commit 2f49389

Please sign in to comment.