mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 01:18:23 +08:00
refactor: use isLeapYear
(#1638)
This commit is contained in:
@ -1,16 +1,33 @@
|
||||
import { getMonthDays } from '../GetMonthDays'
|
||||
|
||||
describe('Get the Days of a Month', () => {
|
||||
it('expects to return 28', () => {
|
||||
expect(getMonthDays(2, 2018)).toEqual(28)
|
||||
})
|
||||
|
||||
it('expects to return 30', () => {
|
||||
expect(getMonthDays(6, 254)).toEqual(30)
|
||||
})
|
||||
|
||||
it('expects to return 29', () => {
|
||||
expect(getMonthDays(2, 2024)).toEqual(29)
|
||||
it.each([
|
||||
[1, 2024, 31],
|
||||
[2, 2024, 29],
|
||||
[3, 2024, 31],
|
||||
[4, 2024, 30],
|
||||
[5, 2024, 31],
|
||||
[6, 2024, 30],
|
||||
[7, 2024, 31],
|
||||
[8, 2024, 31],
|
||||
[9, 2024, 30],
|
||||
[10, 2024, 31],
|
||||
[11, 2024, 30],
|
||||
[12, 2024, 31],
|
||||
[1, 2023, 31],
|
||||
[2, 2023, 28],
|
||||
[3, 2023, 31],
|
||||
[4, 2023, 30],
|
||||
[5, 2023, 31],
|
||||
[6, 2023, 30],
|
||||
[7, 2023, 31],
|
||||
[8, 2023, 31],
|
||||
[9, 2023, 30],
|
||||
[10, 2023, 31],
|
||||
[11, 2023, 30],
|
||||
[12, 2023, 31]
|
||||
])('Month %i in year %i has %i days', (month, year, expected) => {
|
||||
expect(getMonthDays(month, year)).toBe(expected)
|
||||
})
|
||||
|
||||
it('expects to throw a type error', () => {
|
||||
|
Reference in New Issue
Block a user