Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import React from "react";
  2. import { shallow } from "enzyme";
  3. import Router from "next/router";
  4.  
  5. import AgenciesMenu from "../AgenciesMenu";
  6. import { setAgencies, selectAgency } from "../../../logic/hooks/useAgencies";
  7.  
  8. const lyon = { slug: "lyon" };
  9. const paris = { slug: "paris" };
  10. const agencies = [lyon, paris];
  11.  
  12. jest.mock("../../../logic/hooks/useAgencies");
  13.  
  14. test("should match snapshot", () => {
  15. setAgencies(agencies);
  16. const cmp = shallow(<AgenciesMenu />);
  17. expect(cmp).toMatchSnapshot();
  18. });
  19.  
  20. test("should provide a select agency handler which call the action and route", () => {
  21. setAgencies(agencies);
  22.  
  23. const cmp = shallow(<AgenciesMenu />);
  24. const handleAgency = cmp
  25. .find("AgenciesMenu__Item")
  26. .first()
  27. .prop("onClick");
  28.  
  29. handleAgency();
  30.  
  31. expect(selectAgency).toHaveBeenCalled();
  32. expect(Router.push).toHaveBeenCalled();
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement