I am encountering an issue while testing the following code snippet:
https://i.sstatic.net/ImwLs.png
dateUtility.tests.ts:
import { checkDayTime } from "./dateUtility";
describe("utilities/dateUtility", () => {
describe("checkDayTime", () => {
it("should determine if it is day or night based on timestamp", () => {
const dayTime = "Tue Dec 18 2018 12:00:00 GMT-0800 (Pacific Standard Time)";
const nightTime = "Tue Dec 18 2018 20:00:00 GMT-0800 (Pacific Standard Time)";
expect(checkDayTime(new Date(dayTime))).toBeTruthy();
expect(checkDayTime(new Date(nightTime))).toBeFalsy();
});
});
});
dateUtility.ts
export const checkDayTime = (date: Date) => {
const currentHour = date.getHours();
return currentHour > 6 && currentHour < 18;
};
Can you help me identify what is causing the error and provide guidance on how to resolve it?