mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
fixed failing tests
This commit is contained in:
@@ -46,7 +46,7 @@ class DeleteUserButton extends React.Component<Props> {
|
|||||||
const action = confirmDialog ? this.confirmDelete : this.deleteUser;
|
const action = confirmDialog ? this.confirmDelete : this.deleteUser;
|
||||||
|
|
||||||
if (!this.isDeletable()) {
|
if (!this.isDeletable()) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<DeleteButton label="Delete" action={action} loading={entry.loading} />
|
<DeleteButton label="Delete" action={action} loading={entry.loading} />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { configure, shallow } from "enzyme";
|
import { configure, mount, shallow } from "enzyme";
|
||||||
import DeleteUserButton from "./DeleteUserButton";
|
import DeleteUserButton from "./DeleteUserButton";
|
||||||
import Adapter from "enzyme-adapter-react-16";
|
import Adapter from "enzyme-adapter-react-16";
|
||||||
|
|
||||||
@@ -12,42 +12,51 @@ configure({ adapter: new Adapter() });
|
|||||||
|
|
||||||
describe("DeleteUserButton", () => {
|
describe("DeleteUserButton", () => {
|
||||||
it("should render nothing, if the delete link is missing", () => {
|
it("should render nothing, if the delete link is missing", () => {
|
||||||
const user = {
|
const entry = {
|
||||||
|
entry: {
|
||||||
_links: {}
|
_links: {}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const button = shallow(
|
const button = shallow(
|
||||||
<DeleteUserButton user={user} deleteUser={() => {}} />
|
<DeleteUserButton entry={entry} deleteUser={() => {}} />
|
||||||
);
|
);
|
||||||
expect(button.text()).toBe("");
|
expect(button.text()).toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render the button", () => {
|
it("should render the button", () => {
|
||||||
const user = {
|
const entry = {
|
||||||
|
entry: {
|
||||||
_links: {
|
_links: {
|
||||||
delete: {
|
delete: {
|
||||||
href: "/users"
|
href: "/users"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const button = shallow(
|
const button = mount(
|
||||||
<DeleteUserButton user={user} deleteUser={() => {}} />
|
<DeleteUserButton entry={entry} deleteUser={() => {}} />
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(button);
|
||||||
|
|
||||||
expect(button.text()).not.toBe("");
|
expect(button.text()).not.toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should open the confirm dialog on button click", () => {
|
it("should open the confirm dialog on button click", () => {
|
||||||
const user = {
|
const entry = {
|
||||||
|
entry: {
|
||||||
_links: {
|
_links: {
|
||||||
delete: {
|
delete: {
|
||||||
href: "/users"
|
href: "/users"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const button = shallow(
|
const button = mount(
|
||||||
<DeleteUserButton user={user} deleteUser={() => {}} />
|
<DeleteUserButton entry={entry} deleteUser={() => {}} />
|
||||||
);
|
);
|
||||||
button.simulate("click");
|
button.simulate("click");
|
||||||
|
|
||||||
@@ -55,12 +64,14 @@ describe("DeleteUserButton", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should call the delete user function with delete url", () => {
|
it("should call the delete user function with delete url", () => {
|
||||||
const user = {
|
const entry = {
|
||||||
|
entry: {
|
||||||
_links: {
|
_links: {
|
||||||
delete: {
|
delete: {
|
||||||
href: "/users"
|
href: "/users"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let calledUrl = null;
|
let calledUrl = null;
|
||||||
@@ -68,9 +79,9 @@ describe("DeleteUserButton", () => {
|
|||||||
calledUrl = user._links.delete.href;
|
calledUrl = user._links.delete.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
const button = shallow(
|
const button = mount(
|
||||||
<DeleteUserButton
|
<DeleteUserButton
|
||||||
user={user}
|
entry={entry}
|
||||||
confirmDialog={false}
|
confirmDialog={false}
|
||||||
deleteUser={capture}
|
deleteUser={capture}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,24 +8,27 @@ import "raf/polyfill";
|
|||||||
configure({ adapter: new Adapter() });
|
configure({ adapter: new Adapter() });
|
||||||
|
|
||||||
it("should render nothing, if the edit link is missing", () => {
|
it("should render nothing, if the edit link is missing", () => {
|
||||||
const user = {
|
const entry = {
|
||||||
|
entry: {
|
||||||
_links: {}
|
_links: {}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const button = shallow(<EditUserButton user={user} />);
|
const button = shallow(<EditUserButton entry={entry} />);
|
||||||
expect(button.text()).toBe("");
|
expect(button.text()).toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render the button", () => {
|
it("should render the button", () => {
|
||||||
const user = {
|
const entry = {
|
||||||
|
entry: {
|
||||||
_links: {
|
_links: {
|
||||||
update: {
|
update: {
|
||||||
href: "/users"
|
href: "/users"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const button = shallow(<EditUserButton user={user} />);
|
const button = shallow(<EditUserButton entry={entry} />);
|
||||||
expect(button.text()).not.toBe("");
|
expect(button.text()).not.toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user