mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
Fixed minor issues
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
module.exports = {
|
||||
collectCoverage: true,
|
||||
coverageFormats: ["json", "html"]
|
||||
};
|
||||
@@ -27,6 +27,7 @@
|
||||
"build-js": "react-scripts build",
|
||||
"build": "npm-run-all build-css build-js",
|
||||
"test": "jest",
|
||||
"test-coverage": "yarn run test --coverage",
|
||||
"eject": "react-scripts eject",
|
||||
"flow": "flow"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
// @flow
|
||||
import { createUrl } from "./apiclient";
|
||||
|
||||
test("create url, should not change absolute urls", () => {
|
||||
describe("create url", () => {
|
||||
it("should not change absolute urls", () => {
|
||||
expect(createUrl("https://www.scm-manager.org")).toBe(
|
||||
"https://www.scm-manager.org"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("create url, should add prefix for api", () => {
|
||||
it("should add prefix for api", () => {
|
||||
expect(createUrl("/users")).toBe("/scm/api/rest/v2/users");
|
||||
expect(createUrl("users")).toBe("/scm/api/rest/v2/users");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,8 @@ import "raf/polyfill";
|
||||
|
||||
configure({ adapter: new Adapter() });
|
||||
|
||||
it("should render nothing, if the delete link is missing", () => {
|
||||
describe("DeleteUserButton", () => {
|
||||
it("should render nothing, if the delete link is missing", () => {
|
||||
const user = {
|
||||
_links: {}
|
||||
};
|
||||
@@ -19,9 +20,9 @@ it("should render nothing, if the delete link is missing", () => {
|
||||
<DeleteUserButton user={user} deleteUser={() => {}} />
|
||||
);
|
||||
expect(button.text()).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render the button", () => {
|
||||
it("should render the button", () => {
|
||||
const user = {
|
||||
_links: {
|
||||
delete: {
|
||||
@@ -34,9 +35,9 @@ it("should render the button", () => {
|
||||
<DeleteUserButton user={user} deleteUser={() => {}} />
|
||||
);
|
||||
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 = {
|
||||
_links: {
|
||||
delete: {
|
||||
@@ -51,9 +52,9 @@ it("should open the confirm dialog on button click", () => {
|
||||
button.simulate("click");
|
||||
|
||||
expect(confirmAlert.mock.calls.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
it("should call the delete user function with delete url", () => {
|
||||
it("should call the delete user function with delete url", () => {
|
||||
const user = {
|
||||
_links: {
|
||||
delete: {
|
||||
@@ -68,9 +69,14 @@ it("should call the delete user function with delete url", () => {
|
||||
}
|
||||
|
||||
const button = shallow(
|
||||
<DeleteUserButton user={user} confirmDialog={false} deleteUser={capture} />
|
||||
<DeleteUserButton
|
||||
user={user}
|
||||
confirmDialog={false}
|
||||
deleteUser={capture}
|
||||
/>
|
||||
);
|
||||
button.simulate("click");
|
||||
|
||||
expect(calledUrl).toBe("/users");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -82,7 +82,7 @@ class Users extends React.Component<Props, User> {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const userEntries = getUsersFromState(state);
|
||||
var userToEdit = state.users.editUser;
|
||||
const userToEdit = state.users.editUser;
|
||||
if (!userEntries) {
|
||||
return { userToEdit };
|
||||
}
|
||||
|
||||
@@ -125,14 +125,14 @@ const response = {
|
||||
responseBody
|
||||
};
|
||||
|
||||
describe("fetch tests", () => {
|
||||
describe("users fetch()", () => {
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
afterEach(() => {
|
||||
fetchMock.reset();
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
test("successful users fetch", () => {
|
||||
it("should successfully fetch users", () => {
|
||||
fetchMock.getOnce("/scm/api/rest/v2/users", response);
|
||||
|
||||
const expectedActions = [
|
||||
@@ -150,7 +150,7 @@ describe("fetch tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("me fetch failed", () => {
|
||||
it("should fail getting users on HTTP 500", () => {
|
||||
fetchMock.getOnce("/scm/api/rest/v2/users", {
|
||||
status: 500
|
||||
});
|
||||
@@ -164,7 +164,7 @@ describe("fetch tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("successful user add", () => {
|
||||
it("should add a user successfully", () => {
|
||||
fetchMock.postOnce("/scm/api/rest/v2/users", {
|
||||
status: 204
|
||||
});
|
||||
@@ -177,7 +177,7 @@ describe("fetch tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("user add failed", () => {
|
||||
it("should fail adding a user on HTTP 500", () => {
|
||||
fetchMock.postOnce("/scm/api/rest/v2/users", {
|
||||
status: 500
|
||||
});
|
||||
@@ -191,7 +191,7 @@ describe("fetch tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("successful user update", () => {
|
||||
it("successfully update user", () => {
|
||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/users/zaphod", {
|
||||
status: 204
|
||||
});
|
||||
@@ -204,7 +204,7 @@ describe("fetch tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("user update failed", () => {
|
||||
it("should fail updating user on HTTP 500", () => {
|
||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/users/zaphod", {
|
||||
status: 500
|
||||
});
|
||||
@@ -219,15 +219,15 @@ describe("fetch tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("reducer tests", () => {
|
||||
test("users request", () => {
|
||||
var newState = reducer({}, { type: FETCH_USERS });
|
||||
describe("users reducer", () => {
|
||||
test("should update state correctly according to FETCH_USERS action", () => {
|
||||
const newState = reducer({}, { type: FETCH_USERS });
|
||||
expect(newState.loading).toBeTruthy();
|
||||
expect(newState.error).toBeNull();
|
||||
});
|
||||
|
||||
test("fetch users successful", () => {
|
||||
var newState = reducer(
|
||||
it("should update state correctly according to FETCH_USERS_SUCCESS action", () => {
|
||||
const newState = reducer(
|
||||
{},
|
||||
{ type: FETCH_USERS_SUCCESS, payload: responseBody }
|
||||
);
|
||||
@@ -248,7 +248,7 @@ describe("reducer tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("delete user requested", () => {
|
||||
test("should update state correctly according to DELETE_USER action", () => {
|
||||
const state = {
|
||||
usersByNames: {
|
||||
zaphod: {
|
||||
@@ -322,7 +322,7 @@ describe("reducer tests", () => {
|
||||
expect(ford.loading).toBeFalsy();
|
||||
});
|
||||
|
||||
test("reducer does not replace whole usersByNames map", () => {
|
||||
it("should not replace whole usersByNames map when fetching users", () => {
|
||||
const oldState = {
|
||||
usersByNames: {
|
||||
ford: {
|
||||
@@ -339,7 +339,7 @@ describe("reducer tests", () => {
|
||||
expect(newState.usersByNames["ford"]).toBeDefined();
|
||||
});
|
||||
|
||||
test("edit user", () => {
|
||||
it("should update state correctly according to EDIT_USER action", () => {
|
||||
const newState = reducer(
|
||||
{},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user