mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
fixed deleterepo test
This commit is contained in:
@@ -5,11 +5,11 @@ import type { Repository } from "@scm-manager/ui-types";
|
|||||||
import {
|
import {
|
||||||
Subtitle,
|
Subtitle,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
confirmAlert
|
confirmAlert,
|
||||||
|
ErrorNotification
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import { getDeleteRepoFailure, isDeleteRepoPending } from "../modules/repos";
|
import { getDeleteRepoFailure, isDeleteRepoPending } from "../modules/repos";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
|
|||||||
@@ -1,30 +1,40 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { mount, shallow } from "enzyme";
|
import { mount } from "enzyme";
|
||||||
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
||||||
|
import configureStore from "redux-mock-store";
|
||||||
|
|
||||||
import "../../tests/enzyme";
|
import "../../tests/enzyme";
|
||||||
import "../../tests/i18n";
|
import "../../tests/i18n";
|
||||||
import DeleteRepo from "./DeleteRepo";
|
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(),
|
||||||
Subtitle: require.requireActual("@scm-manager/ui-components").Subtitle,
|
Subtitle: require.requireActual("@scm-manager/ui-components").Subtitle,
|
||||||
DeleteButton: require.requireActual("@scm-manager/ui-components").DeleteButton
|
DeleteButton: require.requireActual("@scm-manager/ui-components").DeleteButton,
|
||||||
|
ErrorNotification: ({err}) => err ? err.message : null
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const options = new ReactRouterEnzymeContext();
|
const options = new ReactRouterEnzymeContext();
|
||||||
|
|
||||||
describe("DeleteRepo", () => {
|
describe("DeleteRepo", () => {
|
||||||
|
|
||||||
|
let store;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
store = configureStore()({});
|
||||||
|
});
|
||||||
|
|
||||||
it("should render nothing, if the delete link is missing", () => {
|
it("should render nothing, if the delete link is missing", () => {
|
||||||
const repository = {
|
const repository = {
|
||||||
_links: {}
|
_links: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const navLink = shallow(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} />
|
<DeleteRepo repository={repository} delete={() => {}} store={store} />
|
||||||
);
|
);
|
||||||
expect(navLink.text()).toBe("");
|
expect(navLink.text()).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render the navLink", () => {
|
it("should render the navLink", () => {
|
||||||
@@ -37,7 +47,7 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} />,
|
<DeleteRepo repository={repository} delete={() => {}} store={store} />,
|
||||||
options.get()
|
options.get()
|
||||||
);
|
);
|
||||||
expect(navLink.text()).not.toBe("");
|
expect(navLink.text()).not.toBe("");
|
||||||
@@ -53,7 +63,7 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} />,
|
<DeleteRepo repository={repository} delete={() => {}} store={store} />,
|
||||||
options.get()
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("button").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
@@ -80,6 +90,7 @@ describe("DeleteRepo", () => {
|
|||||||
repository={repository}
|
repository={repository}
|
||||||
confirmDialog={false}
|
confirmDialog={false}
|
||||||
delete={capture}
|
delete={capture}
|
||||||
|
store={store}
|
||||||
/>,
|
/>,
|
||||||
options.get()
|
options.get()
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user