Fixed minor issues

This commit is contained in:
Philipp Czora
2018-07-18 08:31:23 +02:00
parent 727318124c
commit ef4d4b8f02
6 changed files with 83 additions and 78 deletions

View File

@@ -10,67 +10,73 @@ import "raf/polyfill";
configure({ adapter: new Adapter() });
it("should render nothing, if the delete link is missing", () => {
const user = {
_links: {}
};
describe("DeleteUserButton", () => {
it("should render nothing, if the delete link is missing", () => {
const user = {
_links: {}
};
const button = shallow(
<DeleteUserButton user={user} deleteUser={() => {}} />
);
expect(button.text()).toBe("");
});
const button = shallow(
<DeleteUserButton user={user} deleteUser={() => {}} />
);
expect(button.text()).toBe("");
});
it("should render the button", () => {
const user = {
_links: {
delete: {
href: "/users"
it("should render the button", () => {
const user = {
_links: {
delete: {
href: "/users"
}
}
}
};
};
const button = shallow(
<DeleteUserButton user={user} deleteUser={() => {}} />
);
expect(button.text()).not.toBe("");
});
const button = shallow(
<DeleteUserButton user={user} deleteUser={() => {}} />
);
expect(button.text()).not.toBe("");
});
it("should open the confirm dialog on button click", () => {
const user = {
_links: {
delete: {
href: "/users"
it("should open the confirm dialog on button click", () => {
const user = {
_links: {
delete: {
href: "/users"
}
}
}
};
};
const button = shallow(
<DeleteUserButton user={user} deleteUser={() => {}} />
);
button.simulate("click");
const button = shallow(
<DeleteUserButton user={user} deleteUser={() => {}} />
);
button.simulate("click");
expect(confirmAlert.mock.calls.length).toBe(1);
});
expect(confirmAlert.mock.calls.length).toBe(1);
});
it("should call the delete user function with delete url", () => {
const user = {
_links: {
delete: {
href: "/users"
it("should call the delete user function with delete url", () => {
const user = {
_links: {
delete: {
href: "/users"
}
}
};
let calledUrl = null;
function capture(user) {
calledUrl = user._links.delete.href;
}
};
let calledUrl = null;
function capture(user) {
calledUrl = user._links.delete.href;
}
const button = shallow(
<DeleteUserButton
user={user}
confirmDialog={false}
deleteUser={capture}
/>
);
button.simulate("click");
const button = shallow(
<DeleteUserButton user={user} confirmDialog={false} deleteUser={capture} />
);
button.simulate("click");
expect(calledUrl).toBe("/users");
expect(calledUrl).toBe("/users");
});
});