I have created a calendar component which has disabledDateCallback has its props passing back date and further it's formatted to MM/DD/YYYY format.
<CalendarPicker
disabledDateCallback={(date:Date)=>{ //date: Fri Feb 05 2021 17:49:34 GMT+0530(India Standard Time)
const newDate = service.format(date) //newDate: 02/05/2021
return service.holidays.some((d)=>{ // return boolean
newDate === d
})
}}
/>
I'm stuck while writing test case for it as follows, not sure how to test service format and holidays so as to expect a boolean value
it("test for disabled dates", () => {
const calendar = wrapper.find(CalendarPicker);
calendar.props.disabledDateCallback({date: "Fri Feb 05 2021 17:49:34 GMT+0530(India Standard Time)"});
expect....
});
question from:
https://stackoverflow.com/questions/66063690/jest-test-case-for-custom-component 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…