Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] [TS migration] Migrate 'generateMonthMatrixTest.js' test to TypeScript #36167

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import generateMonthMatrix from '../../src/components/DatePicker/CalendarPicker/generateMonthMatrix';
import generateMonthMatrix from '@src/components/DatePicker/CalendarPicker/generateMonthMatrix';

type MonthMatrix = Array<Array<number | null>>;

describe('generateMonthMatrix', () => {
it('returns the correct matrix for January 2022', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, null, null, null, 1, 2],
[3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16],
Expand All @@ -14,7 +16,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for February 2022', () => {
const expected = [
const expected: MonthMatrix = [
[null, 1, 2, 3, 4, 5, 6],
[7, 8, 9, 10, 11, 12, 13],
[14, 15, 16, 17, 18, 19, 20],
Expand All @@ -25,7 +27,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for leap year February 2020', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, null, null, null, 1, 2],
[3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16],
Expand All @@ -36,7 +38,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for March 2022', () => {
const expected = [
const expected: MonthMatrix = [
[null, 1, 2, 3, 4, 5, 6],
[7, 8, 9, 10, 11, 12, 13],
[14, 15, 16, 17, 18, 19, 20],
Expand All @@ -47,7 +49,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for April 2022', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, null, null, 1, 2, 3],
[4, 5, 6, 7, 8, 9, 10],
[11, 12, 13, 14, 15, 16, 17],
Expand All @@ -58,7 +60,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for December 2022', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, null, 1, 2, 3, 4],
[5, 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17, 18],
Expand All @@ -69,7 +71,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for January 2025', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, 1, 2, 3, 4, 5],
[6, 7, 8, 9, 10, 11, 12],
[13, 14, 15, 16, 17, 18, 19],
Expand All @@ -80,7 +82,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for February 2025', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, null, null, null, 1, 2],
[3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16],
Expand All @@ -91,7 +93,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for June 2025', () => {
const expected = [
const expected: MonthMatrix = [
[null, null, null, null, null, null, 1],
[2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15],
Expand All @@ -103,7 +105,7 @@ describe('generateMonthMatrix', () => {
});

it('returns the correct matrix for December 2025', () => {
const expected = [
const expected: MonthMatrix = [
[1, 2, 3, 4, 5, 6, 7],
[8, 9, 10, 11, 12, 13, 14],
[15, 16, 17, 18, 19, 20, 21],
Expand All @@ -125,13 +127,6 @@ describe('generateMonthMatrix', () => {
expect(() => generateMonthMatrix(-1, 0)).toThrow();
});

it('throws an error if year or month is not a number', () => {
expect(() => generateMonthMatrix()).toThrow();
expect(() => generateMonthMatrix(2022, 'invalid')).toThrow();
expect(() => generateMonthMatrix('2022', '0')).toThrow();
expect(() => generateMonthMatrix(null, undefined)).toThrow();
});

Comment on lines -128 to -133
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing that test case since it will be covered by typescript when generateMonthMatrix will be migrated

it('returns a matrix with 6 rows and 7 columns for January 2022', () => {
const matrix = generateMonthMatrix(2022, 0);
expect(matrix.length).toBe(6);
Expand Down
Loading