Tests for doToggle()

This commit is contained in:
Rick Carlino 2018-01-22 14:22:37 -06:00
parent 3e7d1ca1b9
commit 3905c7ee1d

View file

@ -1,6 +1,19 @@
jest.mock("../../config_storage/actions", () => {
return {
toggleWebAppBool: jest.fn(() => "IT WORKS")
};
});
import { doToggle } from "../index";
import { toggleWebAppBool } from "../../config_storage/actions";
describe("doToggle()", () => {
it("calls toggleWebAppBool, but isolated from its parent", () => {
const dispatch = jest.fn();
const toggler = doToggle(dispatch);
const key = "show_first_party_farmware";
toggler(key);
expect(toggleWebAppBool).toHaveBeenCalledWith(key);
expect(dispatch).toHaveBeenCalledWith("IT WORKS");
});
});