Below is the snapshot of my search filter code of table component(react-table). I'm trying to cover test cases for unreachable code using jest. Is their anyway to cover test cases for onAsyncDebounceChange method?
import { React, useMemo, useState } from "react";
import { useAsyncDebounce } from "react-table";
import { Label, Input } from "reactstrap";
import { isValidSearchInput } from "./helper"
// Component for Global Filter
export function GlobalFilter({ globalFilter, setGlobalFilter }) {
const [value, setValue] = useState(globalFilter);
const onChange = value => {
if (isValidSearchInput(value)) {
setValue(value);
onAsyncDebounceChange(value);
}
};
const onAsyncDebounceChange = useAsyncDebounce(value => {
setGlobalFilter (value);
}, 500);
return (
<div>
<Label>Search Table: </Label>
<Input
value={value || ""}
onChange={(e) => {
onChange(e.target.value);
}}
placeholder=" Enter value "
/>
</div>
);
}