Skip to content

Commit

Permalink
add a few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barros001 committed Dec 26, 2023
1 parent 026ee86 commit 5fb6e98
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/unit/generateMonthMatrixTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,51 @@ describe('generateMonthMatrix', () => {
expect(generateMonthMatrix(2022, 11)).toEqual(expected);
});

it('returns the correct matrix for January 2025', () => {
const expected = [
[null, null, 1, 2, 3, 4, 5],
[6, 7, 8, 9, 10, 11, 12],
[13, 14, 15, 16, 17, 18, 19],
[20, 21, 22, 23, 24, 25, 26],
[27, 28, 29, 30, 31, null, null],
];
expect(generateMonthMatrix(2025, 0)).toEqual(expected);
});

it('returns the correct matrix for February 2025', () => {
const expected = [
[null, null, null, null, null, 1, 2],
[3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23],
[24, 25, 26, 27, 28, null, null],
];
expect(generateMonthMatrix(2025, 1)).toEqual(expected);
});

it('returns the correct matrix for June 2025', () => {
const expected = [
[null, null, null, null, null, null, 1],
[2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15],
[16, 17, 18, 19, 20, 21, 22],
[23, 24, 25, 26, 27, 28, 29],
[30, null, null, null, null, null, null],
];
expect(generateMonthMatrix(2025, 5)).toEqual(expected);
});

it('returns the correct matrix for December 2025', () => {
const expected = [
[1, 2, 3, 4, 5, 6, 7],
[8, 9, 10, 11, 12, 13, 14],
[15, 16, 17, 18, 19, 20, 21],
[22, 23, 24, 25, 26, 27, 28],
[29, 30, 31, null, null, null, null],
];
expect(generateMonthMatrix(2025, 11)).toEqual(expected);
});

it('throws an error if month is less than 0', () => {
expect(() => generateMonthMatrix(2022, -1)).toThrow();
});
Expand Down

0 comments on commit 5fb6e98

Please sign in to comment.