From 2a830e4bc4aaaaaa0fc8ec77a79ec4afe44f3fb3 Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Wed, 6 Feb 2019 11:17:06 +0100 Subject: [PATCH] fixed deleterepo test --- scm-ui/src/repos/components/DeleteRepo.js | 4 +-- .../src/repos/components/DeleteRepo.test.js | 25 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scm-ui/src/repos/components/DeleteRepo.js b/scm-ui/src/repos/components/DeleteRepo.js index 4d1b9f3c7c..cca0944f1b 100644 --- a/scm-ui/src/repos/components/DeleteRepo.js +++ b/scm-ui/src/repos/components/DeleteRepo.js @@ -5,11 +5,11 @@ import type { Repository } from "@scm-manager/ui-types"; import { Subtitle, DeleteButton, - confirmAlert + confirmAlert, + ErrorNotification } from "@scm-manager/ui-components"; import { getDeleteRepoFailure, isDeleteRepoPending } from "../modules/repos"; import { connect } from "react-redux"; -import { ErrorNotification } from "@scm-manager/ui-components"; type Props = { loading: boolean, diff --git a/scm-ui/src/repos/components/DeleteRepo.test.js b/scm-ui/src/repos/components/DeleteRepo.test.js index 136cec6c03..3ef7368508 100644 --- a/scm-ui/src/repos/components/DeleteRepo.test.js +++ b/scm-ui/src/repos/components/DeleteRepo.test.js @@ -1,30 +1,40 @@ import React from "react"; -import { mount, shallow } from "enzyme"; +import { mount } from "enzyme"; import ReactRouterEnzymeContext from "react-router-enzyme-context"; +import configureStore from "redux-mock-store"; import "../../tests/enzyme"; import "../../tests/i18n"; import DeleteRepo from "./DeleteRepo"; import { confirmAlert } from "@scm-manager/ui-components"; + jest.mock("@scm-manager/ui-components", () => ({ confirmAlert: jest.fn(), 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(); describe("DeleteRepo", () => { + + let store; + + beforeEach(() => { + store = configureStore()({}); + }); + it("should render nothing, if the delete link is missing", () => { const repository = { _links: {} }; - const navLink = shallow( - {}} /> + const navLink = mount( + {}} store={store} /> ); - expect(navLink.text()).toBe(""); + expect(navLink.text()).toBeNull(); }); it("should render the navLink", () => { @@ -37,7 +47,7 @@ describe("DeleteRepo", () => { }; const navLink = mount( - {}} />, + {}} store={store} />, options.get() ); expect(navLink.text()).not.toBe(""); @@ -53,7 +63,7 @@ describe("DeleteRepo", () => { }; const navLink = mount( - {}} />, + {}} store={store} />, options.get() ); navLink.find("button").simulate("click"); @@ -80,6 +90,7 @@ describe("DeleteRepo", () => { repository={repository} confirmDialog={false} delete={capture} + store={store} />, options.get() );