0

How do I write a test to activate the save button when I choose a date in the datepicker and the onclick function, which holds a state?here is a code snippet....


        if (selectedDate?.filter((e: any) => e.employeeId === employeeId).length > 0) {

            setSelectedDate(selectedDate.map((e: any) => {

                if (e.employeeId === employeeId) {

                    return { ...e, workAnniversary: value }

                }

                else {

                    return { ...e }

                }

            }))

        }



        else {

            setSelectedDate([...selectedDate, { employeeId: employeeId, workAnniversary: value }])

        }

        setIsDisabled(false);

    };
Sreyash
  • 21
  • 5
  • What have you done so far? What testing framework are you using? Are you getting stuck on something specific? – Evert Jan 11 '23 at 06:00
  • @Evert I'm using the React testing library, but I don't know how to test the date picker's onchange feature because I'm new to testing – Sreyash Jan 23 '23 at 09:44

0 Answers0