Skip to content

Commit

Permalink
test: code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Jul 5, 2020
1 parent 55d96bd commit a1e7f9e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/__tests__/useWebAnimations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,6 @@ describe("useWebAnimations", () => {
expect(onUpdate).toHaveBeenNthCalledWith(4, evt);
});

it("should throw polyfill error", () => {
el.animate = null;
renderHelper();
expect(console.error).toHaveBeenCalledWith(polyfillErr);
});

it("should throw event errors", () => {
// @ts-ignore
el.animate = () => ({});
renderHelper({ onReady: () => null });
expect(console.error).toHaveBeenCalledWith(eventErr("onReady"));

renderHelper({ onFinish: () => null });
expect(console.error).toHaveBeenLastCalledWith(eventErr("onFinish"));
});

it("shouldn't call animate if either ref or keyframes isn't set", () => {
renderHelper({ ref: null });
expect(el.animate).not.toHaveBeenCalled();
Expand Down Expand Up @@ -211,4 +195,20 @@ describe("useWebAnimations", () => {
// @ts-ignore
expect(el.animate.mock.results[0].value.playbackRate).toBe(playbackRate);
});

it("should throw polyfill error", () => {
el.animate = null;
renderHelper();
expect(console.error).toHaveBeenCalledWith(polyfillErr);
});

it("should throw event errors", () => {
animation.ready = null;
renderHelper({ onReady: () => null });
expect(console.error).toHaveBeenCalledWith(eventErr("onReady"));

animation.finished = null;
renderHelper({ onFinish: () => null });
expect(console.error).toHaveBeenLastCalledWith(eventErr("onFinish"));
});
});

0 comments on commit a1e7f9e

Please sign in to comment.