Hong-Phuc Bui
2025-01-16 2889de7f0c2d587a17fbd322af57c29e84238620
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import test from "ava";
import {isLeapYear} from "../../src/lib/chronos.js";
 
test( "isLeapYear", t => {
    let year     = [1900, 1904, 1908, 2000, 2004, 2005];
    let expected = [false, true, true, true, true, false];
    for(const [i,y] of Object.entries(year) ) {
        let calculatedLeapYear = isLeapYear(y);
        let leapYear =  expected[i];
        let message = `expected that the year ${y} is ${leapYear?' a' : ' not a'} leap year`
        t.is(calculatedLeapYear, expected[i], message)
    }
});
 
// Code-Comprehension Exercise: proof that the function `weekDayOfDate` only return integers in
// interval [0;6].
 
 
// Unit-Test Exercises: Make Unit Test for other functions
 
// Exercise 1: assert that `countDaysOfMonth` works for leap years (for example 2032)
 
// Exercise 2: assert that `weekDayOfDate` works for leap years