Browse Source

Update testing-recipes.md (#2212)

* Update testing-recipes.md

Update timers section code to match described situation

* Missed a spot
main
Neil Kistner 5 years ago
committed by Sunil Pai
parent
commit
3f6d60a229
  1. 8
      content/docs/testing-recipes.md

8
content/docs/testing-recipes.md

@ -412,7 +412,7 @@ export default function Card(props) {
useEffect(() => { useEffect(() => {
const timeoutID = setTimeout(() => { const timeoutID = setTimeout(() => {
props.onSelect(null); props.onSelect(null);
}, 500); }, 5000);
return () => { return () => {
clearTimeout(timeoutID); clearTimeout(timeoutID);
}; };
@ -467,9 +467,9 @@ it("should select null after timing out", () => {
}); });
expect(onSelect).not.toHaveBeenCalled(); expect(onSelect).not.toHaveBeenCalled();
// and then move ahead by 1 second // and then move ahead by 5 seconds
act(() => { act(() => {
jest.advanceTimersByTime(1000); jest.advanceTimersByTime(5000);
}); });
expect(onSelect).toHaveBeenCalledWith(null); expect(onSelect).toHaveBeenCalledWith(null);
}); });
@ -491,7 +491,7 @@ it("should cleanup on being removed", () => {
}); });
act(() => { act(() => {
jest.advanceTimersByTime(1000); jest.advanceTimersByTime(5000);
}); });
expect(onSelect).not.toHaveBeenCalled(); expect(onSelect).not.toHaveBeenCalled();
}); });

Loading…
Cancel
Save