mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
fixed tests
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { mount, shallow } from "enzyme";
|
import { mount, shallow } from "enzyme";
|
||||||
|
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
||||||
|
|
||||||
import "../../tests/enzyme";
|
import "../../tests/enzyme";
|
||||||
import "../../../tests/i18n";
|
import "../../tests/i18n";
|
||||||
import DeleteGroup from "./DeleteGroup";
|
import DeleteGroup from "./DeleteGroup";
|
||||||
|
|
||||||
import { confirmAlert } from "@scm-manager/ui-components";
|
import { confirmAlert } from "@scm-manager/ui-components";
|
||||||
jest.mock("@scm-manager/ui-components", () => ({
|
jest.mock("@scm-manager/ui-components", () => ({
|
||||||
confirmAlert: jest.fn(),
|
confirmAlert: jest.fn(),
|
||||||
NavAction: require.requireActual("@scm-manager/ui-components").NavAction
|
Subtitle: require.requireActual("@scm-manager/ui-components").Subtitle,
|
||||||
|
DeleteButton: require.requireActual("@scm-manager/ui-components").DeleteButton
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const options = new ReactRouterEnzymeContext();
|
||||||
|
|
||||||
describe("DeleteGroupNavLink", () => {
|
describe("DeleteGroupNavLink", () => {
|
||||||
it("should render nothing, if the delete link is missing", () => {
|
it("should render nothing, if the delete link is missing", () => {
|
||||||
const group = {
|
const group = {
|
||||||
@@ -32,7 +37,8 @@ describe("DeleteGroupNavLink", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteGroup group={group} deleteGroup={() => {}} />
|
<DeleteGroup group={group} deleteGroup={() => {}} />,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
expect(navLink.text()).not.toBe("");
|
expect(navLink.text()).not.toBe("");
|
||||||
});
|
});
|
||||||
@@ -47,9 +53,10 @@ describe("DeleteGroupNavLink", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteGroup group={group} deleteGroup={() => {}} />
|
<DeleteGroup group={group} deleteGroup={() => {}} />,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("a").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
|
|
||||||
expect(confirmAlert.mock.calls.length).toBe(1);
|
expect(confirmAlert.mock.calls.length).toBe(1);
|
||||||
});
|
});
|
||||||
@@ -73,9 +80,10 @@ describe("DeleteGroupNavLink", () => {
|
|||||||
group={group}
|
group={group}
|
||||||
confirmDialog={false}
|
confirmDialog={false}
|
||||||
deleteGroup={capture}
|
deleteGroup={capture}
|
||||||
/>
|
/>,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("a").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
|
|
||||||
expect(calledUrl).toBe("/groups");
|
expect(calledUrl).toBe("/groups");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { mount, shallow } from "enzyme";
|
import { mount, shallow } from "enzyme";
|
||||||
|
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
||||||
|
|
||||||
import "../../tests/enzyme";
|
import "../../tests/enzyme";
|
||||||
import "../../tests/i18n";
|
import "../../tests/i18n";
|
||||||
import DeleteRepo from "./DeleteRepo";
|
import DeleteRepo from "./DeleteRepo";
|
||||||
@@ -7,9 +9,12 @@ import DeleteRepo from "./DeleteRepo";
|
|||||||
import { confirmAlert } from "@scm-manager/ui-components";
|
import { confirmAlert } from "@scm-manager/ui-components";
|
||||||
jest.mock("@scm-manager/ui-components", () => ({
|
jest.mock("@scm-manager/ui-components", () => ({
|
||||||
confirmAlert: jest.fn(),
|
confirmAlert: jest.fn(),
|
||||||
NavAction: require.requireActual("@scm-manager/ui-components").NavAction
|
Subtitle: require.requireActual("@scm-manager/ui-components").Subtitle,
|
||||||
|
DeleteButton: require.requireActual("@scm-manager/ui-components").DeleteButton
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const options = new ReactRouterEnzymeContext();
|
||||||
|
|
||||||
describe("DeleteRepo", () => {
|
describe("DeleteRepo", () => {
|
||||||
it("should render nothing, if the delete link is missing", () => {
|
it("should render nothing, if the delete link is missing", () => {
|
||||||
const repository = {
|
const repository = {
|
||||||
@@ -32,7 +37,8 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} />
|
<DeleteRepo repository={repository} delete={() => {}} />,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
expect(navLink.text()).not.toBe("");
|
expect(navLink.text()).not.toBe("");
|
||||||
});
|
});
|
||||||
@@ -47,9 +53,10 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} />
|
<DeleteRepo repository={repository} delete={() => {}} />,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("a").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
|
|
||||||
expect(confirmAlert.mock.calls.length).toBe(1);
|
expect(confirmAlert.mock.calls.length).toBe(1);
|
||||||
});
|
});
|
||||||
@@ -73,9 +80,10 @@ describe("DeleteRepo", () => {
|
|||||||
repository={repository}
|
repository={repository}
|
||||||
confirmDialog={false}
|
confirmDialog={false}
|
||||||
delete={capture}
|
delete={capture}
|
||||||
/>
|
/>,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("a").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
|
|
||||||
expect(calledUrl).toBe("/repos");
|
expect(calledUrl).toBe("/repos");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ describe("PermissionsNavLink", () => {
|
|||||||
<PermissionsNavLink repository={repository} permissionUrl="" />,
|
<PermissionsNavLink repository={repository} permissionUrl="" />,
|
||||||
options.get()
|
options.get()
|
||||||
);
|
);
|
||||||
expect(navLink.text()).toBe("repository-root.menu.permissions");
|
expect(navLink.text()).toBe("repositoryRoot.menu.permissionsNavLink");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { mount, shallow } from "enzyme";
|
import { mount, shallow } from "enzyme";
|
||||||
|
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
||||||
|
|
||||||
import "../../tests/enzyme";
|
import "../../tests/enzyme";
|
||||||
import "../../../tests/i18n";
|
import "../../tests/i18n";
|
||||||
import DeleteUser from "./DeleteUser";
|
import DeleteUser from "./DeleteUser";
|
||||||
|
|
||||||
import { confirmAlert } from "@scm-manager/ui-components";
|
import { confirmAlert } from "@scm-manager/ui-components";
|
||||||
jest.mock("@scm-manager/ui-components", () => ({
|
jest.mock("@scm-manager/ui-components", () => ({
|
||||||
confirmAlert: jest.fn(),
|
confirmAlert: jest.fn(),
|
||||||
NavAction: require.requireActual("@scm-manager/ui-components").NavAction
|
Subtitle: require.requireActual("@scm-manager/ui-components").Subtitle,
|
||||||
|
DeleteButton: require.requireActual("@scm-manager/ui-components").DeleteButton
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const options = new ReactRouterEnzymeContext();
|
||||||
|
|
||||||
describe("DeleteUser", () => {
|
describe("DeleteUser", () => {
|
||||||
it("should render nothing, if the delete link is missing", () => {
|
it("should render nothing, if the delete link is missing", () => {
|
||||||
const user = {
|
const user = {
|
||||||
@@ -32,7 +37,8 @@ describe("DeleteUser", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteUser user={user} deleteUser={() => {}} />
|
<DeleteUser user={user} deleteUser={() => {}} />,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
expect(navLink.text()).not.toBe("");
|
expect(navLink.text()).not.toBe("");
|
||||||
});
|
});
|
||||||
@@ -47,9 +53,10 @@ describe("DeleteUser", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteUser user={user} deleteUser={() => {}} />
|
<DeleteUser user={user} deleteUser={() => {}} />,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("a").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
|
|
||||||
expect(confirmAlert.mock.calls.length).toBe(1);
|
expect(confirmAlert.mock.calls.length).toBe(1);
|
||||||
});
|
});
|
||||||
@@ -73,9 +80,10 @@ describe("DeleteUser", () => {
|
|||||||
user={user}
|
user={user}
|
||||||
confirmDialog={false}
|
confirmDialog={false}
|
||||||
deleteUser={capture}
|
deleteUser={capture}
|
||||||
/>
|
/>,
|
||||||
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("a").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
|
|
||||||
expect(calledUrl).toBe("/users");
|
expect(calledUrl).toBe("/users");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user