Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
112 views
in Technique[技术] by (71.8m points)

javascript - Jest test case for custom component

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...