github.com/replicatedhq/ship@v0.55.0/web/init/src/components/kustomize/kustomize_overlay/KustomizeOverlay.spec.js (about) 1 import React from "react"; 2 import { mount } from "enzyme"; 3 import KustomizeOverlay from "./KustomizeOverlay"; 4 5 jest.mock("../../shared/DiffEditor"); 6 jest.mock("./AceEditorHOC"); 7 8 const mockKustomizeStep = { 9 kustomize: { 10 basePath: "base", 11 tree: { 12 children: [ 13 { 14 children: [{ 15 name: "deployment.yaml", 16 path: "/deployment.yaml", 17 }], 18 name: "/", 19 path: "/", 20 }, 21 { 22 children: [{ 23 name: "deployment.yaml", 24 path: "/deployment.yaml", 25 }], 26 name: "overlays", 27 path: "/", 28 }, 29 ], 30 } 31 }, 32 }; 33 34 const mockDataLoading = { 35 fileContentLoading: false, 36 }; 37 38 const mockPatch = "This is a mock patch"; 39 40 describe("KustomizeOverlay", () => { 41 describe("select a file with an existing overlay", () => { 42 describe("on click of Show Diff", () => { 43 const wrapper = mount( 44 <KustomizeOverlay 45 currentStep={mockKustomizeStep} 46 dataLoading={mockDataLoading} 47 modified={""} 48 /> 49 ); 50 it("makes a request to generate a new modified", () => { 51 const spy = jest.spyOn(wrapper.instance(), "handleApplyPatch"); 52 53 wrapper.setProps({ 54 patch: mockPatch, 55 }); 56 wrapper.setState({ 57 selectedFile: "/deployment.yaml", 58 }); 59 60 const diffToggle = wrapper.find(".diff-toggle"); 61 diffToggle.simulate("click"); 62 63 expect(spy).toHaveBeenCalled(); 64 }); 65 }); 66 }); 67 });