Testing Leap Year Detection Implementation in dayjs
This test suite validates the isLeapYear plugin functionality in dayjs, ensuring accurate leap year determination for date calculations. The tests verify both positive and negative cases using mock dates to maintain consistent testing conditions.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
iamkun/dayjs
test/plugin/isLeapYear.test.js
import MockDate from 'mockdate'
import dayjs from '../../src'
import isLeapYear from '../../src/plugin/isLeapYear'
dayjs.extend(isLeapYear)
beforeEach(() => {
MockDate.set(new Date())
})
afterEach(() => {
MockDate.reset()
})
it('IsLeapYear', () => {
expect(dayjs('20000101').isLeapYear()).toBe(true)
expect(dayjs('2100-01-01').isLeapYear()).toBe(false)
})