mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-13 04:53:01 +00:00
Lint and make App (Component) functional
This commit is contained in:
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import Enzyme, { mount, shallow } from "enzyme";
|
||||
import GroupEdit from "./GroupEdit.pre";
|
||||
import Adapter from "@wojtekmaj/enzyme-adapter-react-17";
|
||||
import { HashRouter } from 'react-router-dom'
|
||||
import { HashRouter } from "react-router-dom";
|
||||
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("GroupEdit Component: ", () => {
|
||||
var mockAsync = () =>
|
||||
jest.fn().mockImplementation(() => Promise.resolve({ key: "value" }));
|
||||
|
||||
var groupEditJsx = (callbackSpy) =>
|
||||
var groupEditJsx = (callbackSpy) => (
|
||||
<GroupEdit
|
||||
location={{
|
||||
state: {
|
||||
@@ -25,38 +25,37 @@ describe("GroupEdit Component: ", () => {
|
||||
history={{ push: (a) => callbackSpy }}
|
||||
refreshGroupsData={() => {}}
|
||||
/>
|
||||
|
||||
);
|
||||
|
||||
var deepGroupEditJsx = (callbackSpy) => (
|
||||
<HashRouter>
|
||||
{groupEditJsx(callbackSpy)}
|
||||
</HashRouter>
|
||||
<HashRouter>{groupEditJsx(callbackSpy)}</HashRouter>
|
||||
);
|
||||
|
||||
it("Adds a newly selected user to group on submit", () => {
|
||||
let callbackSpy = mockAsync(),
|
||||
component = mount(deepGroupEditJsx(callbackSpy)),
|
||||
unselected = component.find(".unselected"),
|
||||
submit = component.find("#submit")
|
||||
unselected.simulate("click")
|
||||
submit.simulate("click")
|
||||
expect(callbackSpy).toHaveBeenCalledWith(['bar'], "group")
|
||||
})
|
||||
submit = component.find("#submit");
|
||||
unselected.simulate("click");
|
||||
submit.simulate("click");
|
||||
expect(callbackSpy).toHaveBeenCalledWith(["bar"], "group");
|
||||
});
|
||||
|
||||
it("Removes a user from group on submit", () => {
|
||||
let callbackSpy = mockAsync(),
|
||||
component = mount(deepGroupEditJsx(callbackSpy)),
|
||||
selected = component.find(".selected"),
|
||||
submit = component.find("#submit")
|
||||
selected.simulate("click")
|
||||
submit.simulate("click")
|
||||
expect(callbackSpy).toHaveBeenCalledWith(['foo'], "group")
|
||||
})
|
||||
submit = component.find("#submit");
|
||||
selected.simulate("click");
|
||||
submit.simulate("click");
|
||||
expect(callbackSpy).toHaveBeenCalledWith(["foo"], "group");
|
||||
});
|
||||
|
||||
it("Calls deleteGroup on button click", () => {
|
||||
let callbackSpy = mockAsync(),
|
||||
component = shallow(groupEditJsx(callbackSpy)),
|
||||
deleteGroup = component.find("#delete-group").first()
|
||||
deleteGroup.simulate("click")
|
||||
expect(callbackSpy).toHaveBeenCalled()
|
||||
})
|
||||
deleteGroup = component.find("#delete-group").first();
|
||||
deleteGroup.simulate("click");
|
||||
expect(callbackSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user