github.com/replicatedhq/ship@v0.55.0/web/init/src/components/shared/StepTerraform.spec.js (about) 1 import React from "react"; 2 3 import { TERRAFORM_PHASE, StepTerraform } from "./StepTerraform"; 4 import renderer from "react-test-renderer"; 5 6 const mockProps = { 7 location: { 8 pathname: "", 9 }, 10 currentRoute: { 11 phase: TERRAFORM_PHASE, 12 id: "hotdog", 13 }, 14 startPoll: jest.fn(), 15 gotoRoute: jest.fn(), 16 initializeStep: jest.fn(), 17 startPollingStep: jest.fn(), 18 }; 19 20 describe("StepTerraform", () => { 21 describe("provided a status of message", () => { 22 it("renders step message", () => { 23 const propsWithMessage = { 24 ...mockProps, 25 status: { 26 type: "json", 27 detail: JSON.stringify({ 28 status: "message", 29 message: { 30 contents: "this is the message contents", 31 }, 32 }), 33 }, 34 }; 35 const tree = renderer.create( 36 <StepTerraform 37 {...propsWithMessage} 38 /> 39 ).toJSON(); 40 expect(tree).toMatchSnapshot(); 41 }); 42 }); 43 describe("provided a status of error", () => { 44 it("renders the error message", () => { 45 const propsWithError = { 46 ...mockProps, 47 status: { 48 type: "json", 49 detail: JSON.stringify({ 50 status: "error", 51 message: "this is an error", 52 }), 53 } 54 }; 55 const tree = renderer.create( 56 <StepTerraform 57 {...propsWithError} 58 /> 59 ).toJSON(); 60 expect(tree).toMatchSnapshot(); 61 }); 62 }); 63 describe("provided a status of working", () => { 64 it("renders a loader", () => { 65 const propsWithError = { 66 ...mockProps, 67 status: { 68 type: "json", 69 detail: JSON.stringify({ 70 status: "working", 71 }), 72 } 73 }; 74 const tree = renderer.create( 75 <StepTerraform 76 {...propsWithError} 77 /> 78 ).toJSON(); 79 expect(tree).toMatchSnapshot(); 80 }); 81 }); 82 });