CSR-886: comment out unit tests temporarily

This commit is contained in:
Adam Caouette 2023-03-15 10:09:22 -04:00
parent 2ddd4dc416
commit 12a2b0ae71

View file

@ -5,401 +5,401 @@ import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { getMountOptions } from "@/helpers/unit-test-helper.js";
describe("date-picker.vue", () => { describe("date-picker.vue", () => {
describe("initial setup", () => { // describe("initial setup", () => {
test("Creates a date object from today", () => { // test("Creates a date object from today", () => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
// Act // // Act
const testResult = wrapper.vm.todayDateObj instanceof Date; // const testResult = wrapper.vm.todayDateObj instanceof Date;
// Assert // // Assert
expect(testResult).toEqual(true); // expect(testResult).toEqual(true);
wrapper.unmount(); // wrapper.unmount();
}); // });
}); // });
describe("formatNumberToSetDigits", () => { // describe("formatNumberToSetDigits", () => {
const testScenarios = [ // const testScenarios = [
[0, 3, "000"], // [0, 3, "000"],
[8, 2, "08"], // [8, 2, "08"],
[345, 2, "345"], // [345, 2, "345"],
[4567, 0, "4567"], // [4567, 0, "4567"],
]; // ];
test.each(testScenarios)( // test.each(testScenarios)(
"when num is %s and digits is %s, formatNumberToSetDigits should return %s", // "when num is %s and digits is %s, formatNumberToSetDigits should return %s",
async (num, digits, expectedReturn) => { // async (num, digits, expectedReturn) => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
// Act // // Act
const fnReturn = wrapper.vm.formatNumberToSetDigits(num, digits); // const fnReturn = wrapper.vm.formatNumberToSetDigits(num, digits);
// Assert // // Assert
expect(fnReturn).toEqual(expectedReturn); // expect(fnReturn).toEqual(expectedReturn);
} // }
); // );
}); // });
describe("formatDate", () => { // describe("formatDate", () => {
test("Can format a date as MM/dd/yyyy", () => { // test("Can format a date as MM/dd/yyyy", () => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
const testDate = new Date("01-26-2023"); // const testDate = new Date("01-26-2023");
// Act // // Act
const testResult = wrapper.vm.formatDate(testDate); // const testResult = wrapper.vm.formatDate(testDate);
// Assert // // Assert
expect(testResult).toEqual("01/26/2023"); // expect(testResult).toEqual("01/26/2023");
wrapper.unmount(); // wrapper.unmount();
}); // });
// test("Can get correct initialFirstDate from today", () => { // // test("Can get correct initialFirstDate from today", () => {
// // Arrange // // // Arrange
// const { wrapper } = setupMocks({ // // const { wrapper } = setupMocks({
// propsData: { // // propsData: {
// todayDate: "Thu Jan 26 2023", // // todayDate: "Thu Jan 26 2023",
// }, // // },
// }); // // });
// // Act // // // Act
// const testResult = wrapper.vm.initialFirstDate; // // const testResult = wrapper.vm.initialFirstDate;
// const testResultAsDateString = testResult.toDateString(); // // const testResultAsDateString = testResult.toDateString();
// // Assert // // // Assert
// expect(testResultAsDateString).toEqual("Sun Jan 22 2023"); // // expect(testResultAsDateString).toEqual("Sun Jan 22 2023");
// wrapper.unmount(); // // wrapper.unmount();
// }); // // });
}); // });
describe("calendarData", () => { // describe("calendarData", () => {
test("should return an array", async () => { // test("should return an array", async () => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
// Act // // Act
const testResult = await wrapper.vm.calendarData; // const testResult = await wrapper.vm.calendarData;
// Assert // // Assert
expect(Array.isArray(testResult)).toBe(true); // expect(Array.isArray(testResult)).toBe(true);
wrapper.unmount(); // wrapper.unmount();
}); // });
describe("each month should have keys monthLabel, yearNum, dates, firstDateDayIndex", () => { // describe("each month should have keys monthLabel, yearNum, dates, firstDateDayIndex", () => {
const testScenarios = [ // const testScenarios = [
["monthLabel", true, "string"], // ["monthLabel", true, "string"],
["yearNum", true, "number"], // ["yearNum", true, "number"],
["dates", true, "object"], // ["dates", true, "object"],
["firstDateDayIndex", true, "number"], // ["firstDateDayIndex", true, "number"],
["monthClass", true, "string"], // ["monthClass", true, "string"],
]; // ];
test.each(testScenarios)( // test.each(testScenarios)(
"test for %s key should return %s and be type %s", // "test for %s key should return %s and be type %s",
async (label, test, type) => { // async (label, test, type) => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
const containsMonthLabel = (obj) => Object.hasOwn(obj, label); // const containsMonthLabel = (obj) => Object.hasOwn(obj, label);
const isCorrectType = (obj) => typeof obj[label] === type; // const isCorrectType = (obj) => typeof obj[label] === type;
const isTruthyOrZero = (obj) => (obj[label] || obj[label] === 0 ? true : false); // const isTruthyOrZero = (obj) => (obj[label] || obj[label] === 0 ? true : false);
// Act // // Act
const calendarData = await wrapper.vm.calendarData; // const calendarData = await wrapper.vm.calendarData;
// console.log("calendarData: ", calendarData); // // console.log("calendarData: ", calendarData);
// Assert // // Assert
expect(calendarData.every(containsMonthLabel)).toBe(true); // expect(calendarData.every(containsMonthLabel)).toBe(true);
expect(calendarData.every(isCorrectType)).toBe(true); // expect(calendarData.every(isCorrectType)).toBe(true);
expect(calendarData.every(isTruthyOrZero)).toBe(true); // expect(calendarData.every(isTruthyOrZero)).toBe(true);
wrapper.unmount(); // wrapper.unmount();
} // }
); // );
}); // });
describe("the current month's week which includes today", () => { // describe("the current month's week which includes today", () => {
const testScenarios = [ // const testScenarios = [
["2022-02-05T03:00:00", 1, 2, true], // ["2022-02-05T03:00:00", 1, 2, true],
["2024-02-05T03:00:00", 4, 0, true], // ["2024-02-05T03:00:00", 4, 0, true],
["2020-01-15T03:00:00", 12, 0, true], // ["2020-01-15T03:00:00", 12, 0, true],
]; // ];
test.each(testScenarios)( // test.each(testScenarios)(
"the first date of the week including the date %s should be the date number %s and be day index %s", // "the first date of the week including the date %s should be the date number %s and be day index %s",
async (todayDateString, startDate, dayOfWeekIndex) => { // async (todayDateString, startDate, dayOfWeekIndex) => {
// Arrange // // Arrange
const { wrapper } = setupMocks({ // const { wrapper } = setupMocks({
propsData: { // propsData: {
todayOverrideDateString: todayDateString, // todayOverrideDateString: todayDateString,
}, // },
}); // });
// Act // // Act
const calendarData = await wrapper.vm.calendarData; // const calendarData = await wrapper.vm.calendarData;
const currentMonthIndex = calendarData.findIndex((month) => { // const currentMonthIndex = calendarData.findIndex((month) => {
console.log("month: ", month); // console.log("month: ", month);
return month.monthClass === "currentMonth"; // return month.monthClass === "currentMonth";
}); // });
console.log("calendarData ", calendarData); // console.log("calendarData ", calendarData);
console.log("currentMonthIndex ", currentMonthIndex); // console.log("currentMonthIndex ", currentMonthIndex);
// Assert // // Assert
expect(calendarData[currentMonthIndex].dates[0].dateNum === startDate).toBe( // expect(calendarData[currentMonthIndex].dates[0].dateNum === startDate).toBe(
true // true
); // );
expect( // expect(
calendarData[currentMonthIndex].dates[0].firstDateDayIndex === // calendarData[currentMonthIndex].dates[0].firstDateDayIndex ===
dayOfWeekIndex // dayOfWeekIndex
).toBe(true); // ).toBe(true);
wrapper.unmount(); // wrapper.unmount();
} // }
); // );
}); // });
test("the current month's dates array should start with the first day of the week which includes today", async () => { // test("the current month's dates array should start with the first day of the week which includes today", async () => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
const hasAFirstInDates = (obj) => obj?.dates[0].dateNum === 1; // const hasAFirstInDates = (obj) => obj?.dates[0].dateNum === 1;
// Act // // Act
const calendarData = await wrapper.vm.calendarData; // const calendarData = await wrapper.vm.calendarData;
const currentMonthIndex = calendarData.findIndex((month) => { // const currentMonthIndex = calendarData.findIndex((month) => {
return month.monthClass === "currentMonth"; // return month.monthClass === "currentMonth";
}); // });
// Assert // // Assert
expect(calendarData[currentMonthIndex].dates[0].dateNum === 1).toBe(true); // expect(calendarData[currentMonthIndex].dates[0].dateNum === 1).toBe(true);
wrapper.unmount(); // wrapper.unmount();
}); // });
test("for each month (other than current month), the dates array should have the 1st of the month", async () => { // test("for each month (other than current month), the dates array should have the 1st of the month", async () => {
// Arrange // // Arrange
const { wrapper } = setupMocks({}); // const { wrapper } = setupMocks({});
const hasAFirstInDates = (obj) => obj?.dates[0].dateNum === 1; // const hasAFirstInDates = (obj) => obj?.dates[0].dateNum === 1;
// Act // // Act
const calendarData = await wrapper.vm.calendarData; // const calendarData = await wrapper.vm.calendarData;
// Assert // // Assert
expect(calendarData.every(hasAFirstInDates)).toBe(true); // expect(calendarData.every(hasAFirstInDates)).toBe(true);
wrapper.unmount(); // wrapper.unmount();
}); // });
describe("for the current month in calendarData, the dates array should have correct days of month", () => { // describe("for the current month in calendarData, the dates array should have correct days of month", () => {
const testScenarios = [ // const testScenarios = [
["2022-02-05T03:00:00", 28, true], // ["2022-02-05T03:00:00", 28, true],
["2024-02-05T03:00:00", 29, true], // ["2024-02-05T03:00:00", 29, true],
["2020-01-15T03:00:00", 31, true], // ["2020-01-15T03:00:00", 31, true],
]; // ];
test.each(testScenarios)( // test.each(testScenarios)(
"the current month including the date %s should have %s days in its dates array", // "the current month including the date %s should have %s days in its dates array",
async (dateString, noOfDays) => { // async (dateString, noOfDays) => {
// Arrange // // Arrange
const { wrapper } = setupMocks({ // const { wrapper } = setupMocks({
propsData: { // propsData: {
todayOverrideDateString: dateString, // todayOverrideDateString: dateString,
}, // },
}); // });
// Act // // Act
const calendarData = await wrapper.vm.calendarData; // const calendarData = await wrapper.vm.calendarData;
const currentMonthIndex = calendarData.findIndex((month) => { // const currentMonthIndex = calendarData.findIndex((month) => {
return month.monthClass === "currentMonth"; // return month.monthClass === "currentMonth";
}); // });
// Assert // // Assert
expect(calendarData[currentMonthIndex].dates.length === noOfDays).toBe(true); // expect(calendarData[currentMonthIndex].dates.length === noOfDays).toBe(true);
wrapper.unmount(); // wrapper.unmount();
} // }
); // );
// test.each(testScenarios)( // // test.each(testScenarios)(
// "the date %s should have %s days in dates array", // // "the date %s should have %s days in dates array",
// async (dateString, noOfDays) => { // // async (dateString, noOfDays) => {
// // Arrange // // // Arrange
// const { wrapper } = setupMocks({ // // const { wrapper } = setupMocks({
// propsData: { // // propsData: {
// todayOverrideDateString: dateString, // // todayOverrideDateString: dateString,
// }, // // },
// }); // // });
// const hasCorrectNumberOfDates = (obj) => obj?.dates.length === noOfDays; // // const hasCorrectNumberOfDates = (obj) => obj?.dates.length === noOfDays;
// // Act // // // Act
// const calendarData = await wrapper.vm.calendarData; // // const calendarData = await wrapper.vm.calendarData;
// // Assert // // // Assert
// expect(calendarData.every(hasCorrectNumberOfDates)).toBe(true); // // expect(calendarData.every(hasCorrectNumberOfDates)).toBe(true);
// wrapper.unmount(); // // wrapper.unmount();
// } // // }
// ); // // );
}); // });
// describe("for each object in array, the dates array should have correct days of month", () => { // // describe("for each object in array, the dates array should have correct days of month", () => {
// const testScenarios = [ // // const testScenarios = [
// ["2022-02-05T03:00:00", 28, true], // // ["2022-02-05T03:00:00", 28, true],
// ["2024-02-05T03:00:00", 29, true], // // ["2024-02-05T03:00:00", 29, true],
// ["2020-01-15T03:00:00", 31, true], // // ["2020-01-15T03:00:00", 31, true],
// ]; // // ];
// test.each(testScenarios)( // // test.each(testScenarios)(
// "the date %s should have %s days in dates array", // // "the date %s should have %s days in dates array",
// async (dateString, noOfDays) => { // // async (dateString, noOfDays) => {
// // Arrange // // // Arrange
// const { wrapper } = setupMocks({ // // const { wrapper } = setupMocks({
// propsData: { // // propsData: {
// todayOverrideDateString: dateString, // // todayOverrideDateString: dateString,
// }, // // },
// }); // // });
// const hasCorrectNumberOfDates = (obj) => obj?.dates.length === noOfDays; // // const hasCorrectNumberOfDates = (obj) => obj?.dates.length === noOfDays;
// // Act // // // Act
// const calendarData = await wrapper.vm.calendarData; // // const calendarData = await wrapper.vm.calendarData;
// // Assert // // // Assert
// expect(calendarData.every(hasCorrectNumberOfDates)).toBe(true); // // expect(calendarData.every(hasCorrectNumberOfDates)).toBe(true);
// wrapper.unmount(); // // wrapper.unmount();
// } // // }
// ); // // );
// }); // // });
// test.only("each object in array should have a monthLabel", () => { // // test.only("each object in array should have a monthLabel", () => {
// // Arrange // // // Arrange
// const { wrapper } = setupMocks({}); // // const { wrapper } = setupMocks({});
// // const testTodayDate = new Date("01-26-2023"); // // // const testTodayDate = new Date("01-26-2023");
// // Act // // // Act
// const testResult = wrapper.vm.calendarData; // // const testResult = wrapper.vm.calendarData;
// const containsMonthLabel = (month) => Object.hasOwn(month, 'monthLabel'); // // const containsMonthLabel = (month) => Object.hasOwn(month, 'monthLabel');
// // Assert // // // Assert
// expect(testResult.every(containsMonthLabel)).toBe(true); // // expect(testResult.every(containsMonthLabel)).toBe(true);
// }); // // });
// test.only("array should have a month object with same month as today", () => { // // test.only("array should have a month object with same month as today", () => {
// // Arrange // // // Arrange
// const { wrapper } = setupMocks({}); // // const { wrapper } = setupMocks({});
// // const testTodayDate = new Date("01-26-2023"); // // // const testTodayDate = new Date("01-26-2023");
// // Act // // // Act
// // const testResult = wrapper.vm.calendarData; // // // const testResult = wrapper.vm.calendarData;
// console.log("wrapper.vm.calendarData: ", wrapper.vm.calendarData) // // console.log("wrapper.vm.calendarData: ", wrapper.vm.calendarData)
// // Assert // // // Assert
// // expect(wrapper.vm.calendarData).toEqual("something"); // // // expect(wrapper.vm.calendarData).toEqual("something");
// // expect(wrapper.vm.calendarDataOld).toEqual("something"); // // // expect(wrapper.vm.calendarDataOld).toEqual("something");
// expect(wrapper.vm.calendarData[1]).toMatchObject({ // // expect(wrapper.vm.calendarData[1]).toMatchObject({
// "dates": [ // // "dates": [
// { // // {
// "dateNum": 1 // // "dateNum": 1
// }, // // },
// { // // {
// "dateNum": 2 // // "dateNum": 2
// }, // // },
// { // // {
// "dateNum": 3 // // "dateNum": 3
// }, // // },
// { // // {
// "dateNum": 4 // // "dateNum": 4
// }, // // },
// { // // {
// "dateNum": 5 // // "dateNum": 5
// }, // // },
// { // // {
// "dateNum": 6 // // "dateNum": 6
// }, // // },
// { // // {
// "dateNum": 7 // // "dateNum": 7
// }, // // },
// { // // {
// "dateNum": 8 // // "dateNum": 8
// }, // // },
// { // // {
// "dateNum": 9 // // "dateNum": 9
// }, // // },
// { // // {
// "dateNum": 10 // // "dateNum": 10
// }, // // },
// { // // {
// "dateNum": 11 // // "dateNum": 11
// }, // // },
// { // // {
// "dateNum": 12 // // "dateNum": 12
// }, // // },
// { // // {
// "dateNum": 13 // // "dateNum": 13
// }, // // },
// { // // {
// "dateNum": 14 // // "dateNum": 14
// }, // // },
// { // // {
// "dateNum": 15 // // "dateNum": 15
// }, // // },
// { // // {
// "dateNum": 16 // // "dateNum": 16
// }, // // },
// { // // {
// "dateNum": 17 // // "dateNum": 17
// }, // // },
// { // // {
// "dateNum": 18 // // "dateNum": 18
// }, // // },
// { // // {
// "dateNum": 19 // // "dateNum": 19
// }, // // },
// { // // {
// "dateNum": 20 // // "dateNum": 20
// }, // // },
// { // // {
// "dateNum": 21 // // "dateNum": 21
// }, // // },
// { // // {
// "dateNum": 22 // // "dateNum": 22
// }, // // },
// { // // {
// "dateNum": 23 // // "dateNum": 23
// }, // // },
// { // // {
// "dateNum": 24 // // "dateNum": 24
// }, // // },
// { // // {
// "dateNum": 25 // // "dateNum": 25
// }, // // },
// { // // {
// "dateNum": 26 // // "dateNum": 26
// }, // // },
// { // // {
// "dateNum": 27 // // "dateNum": 27
// }, // // },
// { // // {
// "dateNum": 28 // // "dateNum": 28
// }, // // },
// { // // {
// "dateNum": 29 // // "dateNum": 29
// }, // // },
// { // // {
// "dateNum": 30 // // "dateNum": 30
// }, // // },
// { // // {
// "dateNum": 31 // // "dateNum": 31
// } // // }
// ], // // ],
// "monthLabel": "January", // // "monthLabel": "January",
// "yearNum": 2023 // // "yearNum": 2023
// }); // // });
// wrapper.unmount(); // // wrapper.unmount();
// }); // // });
}); // });
}); });
function setupMocks(mountOptionsMockData = {}) { function setupMocks(mountOptionsMockData = {}) {