Added missing files

hg did not show them as added
This commit is contained in:
Philipp Czora
2018-07-17 16:27:45 +02:00
parent db9e468877
commit b85776cb1d
4 changed files with 71 additions and 0 deletions

4
scm-ui/jest.config.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = {
collectCoverage: true,
coverageFormats: ["json", "html"]
};

View File

@@ -0,0 +1,29 @@
//@flow
import React from "react";
import type { User } from "../types/User";
type Props = {
user: User,
editUser: User => void
};
type State = {};
class EditUserButton extends React.Component<Props, State> {
render() {
if (!this.isEditable()) {
return "";
}
return (
<button type="button" onClick={e => this.props.editUser(this.props.user)}>
Edit user
</button>
);
}
isEditable = () => {
return this.props.user._links.update;
};
}
export default EditUserButton;

View File

@@ -0,0 +1,31 @@
import React from "react";
import { configure, shallow } from "enzyme";
import EditUserButton from "./EditUserButton";
import Adapter from "enzyme-adapter-react-16";
import "raf/polyfill";
configure({ adapter: new Adapter() });
it("should render nothing, if the edit link is missing", () => {
const user = {
_links: {}
};
const button = shallow(<EditUserButton user={user} />);
expect(button.text()).toBe("");
});
it("should render the button", () => {
const user = {
_links: {
update: {
href: "/users"
}
}
};
const button = shallow(<EditUserButton user={user} />);
expect(button.text()).not.toBe("");
});

View File

@@ -0,0 +1,7 @@
type UserEntry = {
loading: boolean,
error: Error,
user: User
};
export type UserEntry;