I have this test:
describe("onAfterSwipe", () => {
it("Should call a handler after swiping", async () => {
const onAfterSwipe = jest.fn();
const wrapper = mount(
<Swipeable onAfterSwipe={onAfterSwipe}>Hello</Swipeable>
);
swipe(wrapper, 500);
await wait(600);
expect(onAfterSwipe).toHaveBeenCalledTimes(1);
});
});
I'm waiting for 600ms to check if the function was called (onAfterSwipe is called after an animation end), i would like to do something like:
describe("onAfterSwipe", () => {
it("Should call a handler after swiping", (done) => {
const onAfterSwipe = jest.fn();
const wrapper = mount(
<Swipeable onAfterSwipe={onAfterSwipe}>Hello</Swipeable>
);
swipe(wrapper, 500);
onAfterSwipe.called((args) => {
expect(onAfterSwipe).toHaveBeenCalledWith("right");
done();
})
});
});
Aucun commentaire:
Enregistrer un commentaire