Improved flow coverage, fixed bugs and enabled deleting users

This commit is contained in:
Philipp Czora
2018-07-11 12:02:53 +02:00
parent 8f30907e96
commit e3caa93aa7
11 changed files with 118 additions and 91 deletions

View File

@@ -1,42 +1,39 @@
import React from 'react';
import {configure, shallow} from 'enzyme';
import React from "react";
import { configure, shallow } from "enzyme";
import DeleteUserButton from "./DeleteUserButton";
import Adapter from 'enzyme-adapter-react-16';
import Adapter from "enzyme-adapter-react-16";
import 'raf/polyfill';
import "raf/polyfill";
configure({ adapter: new Adapter() });
it('should render nothing, if the delete link is missing', () => {
it("should render nothing, if the delete link is missing", () => {
const user = {
_links: {}
};
const button = shallow(<DeleteUserButton user={ user } />);
const button = shallow(<DeleteUserButton user={user} />);
expect(button.text()).toBe("");
});
it('should render the button', () => {
it("should render the button", () => {
const user = {
_links: {
"delete": {
"href": "/users"
delete: {
href: "/users"
}
}
};
const button = shallow(<DeleteUserButton user={ user } />);
const button = shallow(<DeleteUserButton user={user} />);
expect(button.text()).not.toBe("");
});
it('should call the delete user function with delete url', () => {
it("should call the delete user function with delete url", () => {
const user = {
_links: {
"delete": {
"href": "/users"
delete: {
href: "/users"
}
}
};
@@ -47,7 +44,7 @@ it('should call the delete user function with delete url', () => {
calledUrl = url;
}
const button = shallow(<DeleteUserButton user={ user } deleteUser={ capture } />);
const button = shallow(<DeleteUserButton user={user} deleteUser={capture} />);
button.simulate("click");
expect(calledUrl).toBe("/users");