Farmbot-Web-App/webpack/account/labs/__tests__/labs_features_test.tsx
2017-10-24 16:42:20 -05:00

31 lines
855 B
TypeScript

const mockFeatures = [
{
name: "Weed Detection",
description: "Plots points of weeds in the garden.",
storageKey: "weedDetector",
callback: jest.fn(),
value: false
}
];
const mocks = {
"maybeToggleFeature": jest.fn(),
"fetchLabFeatures": jest.fn(() => mockFeatures)
};
jest.mock("../labs_features_list_data", () => mocks);
import * as React from "react";
import { mount } from "enzyme";
import { LabsFeatures } from "../labs_features";
describe("<LabsFeatures/>", () => {
it("triggers the correct callback on click", () => {
const el = mount(<LabsFeatures />);
expect(mocks.fetchLabFeatures.mock.calls.length).toBeGreaterThan(0);
el.find("button").simulate("click");
expect(mockFeatures[0].callback).toHaveBeenCalled();
expect(mocks.maybeToggleFeature.mock.calls.length).toBeGreaterThan(0);
});
});