Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from "react";
- import { shallow } from "enzyme";
- import Router from "next/router";
- import AgenciesMenu from "../AgenciesMenu";
- import { setAgencies, selectAgency } from "../../../logic/hooks/useAgencies";
- const lyon = { slug: "lyon" };
- const paris = { slug: "paris" };
- const agencies = [lyon, paris];
- jest.mock("../../../logic/hooks/useAgencies");
- test("should match snapshot", () => {
- setAgencies(agencies);
- const cmp = shallow(<AgenciesMenu />);
- expect(cmp).toMatchSnapshot();
- });
- test("should provide a select agency handler which call the action and route", () => {
- setAgencies(agencies);
- const cmp = shallow(<AgenciesMenu />);
- const handleAgency = cmp
- .find("AgenciesMenu__Item")
- .first()
- .prop("onClick");
- handleAgency();
- expect(selectAgency).toHaveBeenCalled();
- expect(Router.push).toHaveBeenCalled();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement