Lint and make App (Component) functional

This commit is contained in:
Nathan Barber
2021-04-07 15:36:17 -04:00
parent 1d705193cb
commit cadcb686c9
9 changed files with 82 additions and 123 deletions

View File

@@ -9,26 +9,27 @@ describe("CreateGroup Component: ", () => {
var mockAsync = () =>
jest.fn().mockImplementation(() => Promise.resolve({ key: "value" }));
var createGroupJsx = (callbackSpy) =>
var createGroupJsx = (callbackSpy) => (
<CreateGroup
createGroup={callbackSpy}
refreshGroupsData={callbackSpy}
history={{push: () => {}}}
history={{ push: () => {} }}
/>
);
it("Renders", () => {
let component = shallow(createGroupJsx())
expect(component.find(".container").length).toBe(1)
})
let component = shallow(createGroupJsx());
expect(component.find(".container").length).toBe(1);
});
it("Calls createGroup and refreshGroupsData on submit", () => {
let callbackSpy = mockAsync(),
component = shallow(createGroupJsx(callbackSpy)),
input = component.find("input").first(),
submit = component.find("#submit").first()
input.simulate("change", { target: { value: "" } })
submit.simulate("click")
expect(callbackSpy).toHaveBeenNthCalledWith(1, "")
expect(callbackSpy).toHaveBeenNthCalledWith(2)
})
})
submit = component.find("#submit").first();
input.simulate("change", { target: { value: "" } });
submit.simulate("click");
expect(callbackSpy).toHaveBeenNthCalledWith(1, "");
expect(callbackSpy).toHaveBeenNthCalledWith(2);
});
});