fixed failing tests and added helper for tests with i18n

This commit is contained in:
Sebastian Sdorra
2018-07-24 16:13:48 +02:00
parent fd01cb0573
commit 980bd5b98c
4 changed files with 9 additions and 2 deletions

7
scm-ui/src/tests/i18n.js Normal file
View File

@@ -0,0 +1,7 @@
jest.mock("react-i18next", () => ({
// this mock makes sure any components using the translate HoC receive the t function as a prop
translate: () => Component => {
Component.defaultProps = { ...Component.defaultProps, t: key => key };
return Component;
}
}));

View File

@@ -1,6 +1,7 @@
import React from "react";
import { mount, shallow } from "enzyme";
import "../../tests/enzyme";
import "../../tests/i18n";
import DeleteUserButton from "./DeleteUserButton";
import { confirmAlert } from "../../components/ConfirmAlert";

View File

@@ -1,6 +1,7 @@
import React from "react";
import { configure, shallow } from "enzyme";
import "../../tests/enzyme";
import "../../tests/i18n";
import EditUserButton from "./EditUserButton";
it("should render nothing, if the edit link is missing", () => {

View File

@@ -154,7 +154,6 @@ export function createUserPending(user: User) {
};
}
export function createUserSuccess() {
return {
type: CREATE_USER_SUCCESS
@@ -181,7 +180,6 @@ export function modifyUser(user: User) {
dispatch(fetchUsers());
})
.catch(err => {
console.log(err);
dispatch(modifyUserFailure(user, err));
});
};