Reconfigure tests to work with hook approach

This commit is contained in:
Nathan Barber
2021-04-07 15:25:21 -04:00
parent b230745d64
commit 4768751125
13 changed files with 129 additions and 87 deletions

View File

@@ -18,31 +18,10 @@ describe("EditUser Component: ", () => {
refreshUserData={mockSync()}
history={{ push: (a) => {} }}
failRegexEvent={callbackSpy}
noChangeEvent={callbackSpy}
/>
);
it("Updates the state whenever a key is pressed on the textarea", () => {
let component = shallow(editUserJsx(mockAsync())),
textarea = component.find("textarea");
textarea.simulate("keydown", { target: { value: "test" } });
expect(component.state("updated_username")).toBe("test");
});
it("Updates the state whenever the admin box changes", () => {
let component = shallow(editUserJsx(mockAsync())),
admin = component.find("#admin-check");
admin.simulate("change", { target: { checked: true } });
expect(component.state("admin")).toBe(true);
});
it("Delimits the input from the textarea", () => {
let component = shallow(editUserJsx(mockAsync())),
submit = component.find("#submit");
component.setState({ updated_username: "%!@$#&" });
submit.simulate("click");
expect(component.state("updated_username")).toBe("");
});
it("Calls the delete user function when the button is pressed", () => {
let callbackSpy = mockAsync(),
component = shallow(editUserJsx(callbackSpy)),
@@ -52,11 +31,9 @@ describe("EditUser Component: ", () => {
});
it("Submits the edits when the button is pressed", () => {
let callbackSpy = mockAsync(),
let callbackSpy = mockSync(),
component = shallow(editUserJsx(callbackSpy)),
submit = component.find("#submit"),
textarea = component.find("textarea");
textarea.simulate("keydown", { target: { value: "test" } });
submit = component.find("#submit");
submit.simulate("click");
expect(callbackSpy).toHaveBeenCalled();
});