From c095ba68ebd145ae55dbbd2aefa8fa3da3e34437 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 24 Mar 2020 11:27:30 -0700 Subject: [PATCH] BOD-58 WIP For testing classes. No success. --- bodyshop_translations.babel | 63 ++++++++ client/src/App/App.test.js | 18 --- .../alert.component.test.js.snap | 3 + .../components/alert/alert.component.test.js | 18 ++- ...ocations-assignment.component.test.js.snap | 5 + .../allocations-assignment.component.jsx | 23 ++- .../allocations-assignment.component.test.js | 38 +++++ .../allocations-assignment.container.test.jsx | 20 --- client/src/graphql/jobs.queries.js | 1 + .../jobs-create/jobs-create.component.jsx | 97 +++++++----- .../jobs-create/jobs-create.container.jsx | 30 +++- client/src/translations/en_us/common.json | 3 + client/src/translations/es/common.json | 3 + client/src/translations/fr/common.json | 3 + client/src/utils/TestingHelpers.js | 148 ++++++++++++++++++ 15 files changed, 376 insertions(+), 97 deletions(-) delete mode 100644 client/src/App/App.test.js create mode 100644 client/src/components/alert/__snapshots__/alert.component.test.js.snap create mode 100644 client/src/components/allocations-assignment/__snapshots__/allocations-assignment.component.test.js.snap delete mode 100644 client/src/components/allocations-assignment/allocations-assignment.container.test.jsx create mode 100644 client/src/utils/TestingHelpers.js diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index adb7a9610..d1940eaba 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -4151,6 +4151,27 @@ + + gotojob + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + manualnew false @@ -7121,6 +7142,48 @@ + + created_subtitle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + creatednoclick + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + deleted false diff --git a/client/src/App/App.test.js b/client/src/App/App.test.js deleted file mode 100644 index 945ec6f4a..000000000 --- a/client/src/App/App.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App.container"; -import { MockedProvider } from "@apollo/react-testing"; -const div = document.createElement("div"); - -it("renders without crashing", () => { - ReactDOM.render( - - - , - div - ); -}); - -it("unmounts without crashing", () => { - ReactDOM.unmountComponentAtNode(div); -}); diff --git a/client/src/components/alert/__snapshots__/alert.component.test.js.snap b/client/src/components/alert/__snapshots__/alert.component.test.js.snap new file mode 100644 index 000000000..b872ff7b9 --- /dev/null +++ b/client/src/components/alert/__snapshots__/alert.component.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Alert component should render Alert component 1`] = `ShallowWrapper {}`; diff --git a/client/src/components/alert/alert.component.test.js b/client/src/components/alert/alert.component.test.js index da5d57cb8..74e75f337 100644 --- a/client/src/components/alert/alert.component.test.js +++ b/client/src/components/alert/alert.component.test.js @@ -6,8 +6,18 @@ import { shallow, mount } from "enzyme"; const div = document.createElement("div"); -it("renders without crashing", () => { - const wrapper = mount(); - console.log("wrapper", wrapper); - // expect(wrapper.children()).to.have.lengthOf(1); +describe("Alert component", () => { + let wrapper; + beforeEach(() => { + const mockProps = { + type: "error", + message: "Test error message." + }; + + wrapper = shallow(); + }); + + it("should render Alert component", () => { + expect(wrapper).toMatchSnapshot(); + }); }); diff --git a/client/src/components/allocations-assignment/__snapshots__/allocations-assignment.component.test.js.snap b/client/src/components/allocations-assignment/__snapshots__/allocations-assignment.component.test.js.snap new file mode 100644 index 000000000..c0b9ed61d --- /dev/null +++ b/client/src/components/allocations-assignment/__snapshots__/allocations-assignment.component.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AllocationsAssignmentComponent component should create an allocation on save 1`] = `ReactWrapper {}`; + +exports[`AllocationsAssignmentComponent component should render AllocationsAssignmentComponent component 1`] = `ReactWrapper {}`; diff --git a/client/src/components/allocations-assignment/allocations-assignment.component.jsx b/client/src/components/allocations-assignment/allocations-assignment.component.jsx index b02f09bc2..bc6273bdb 100644 --- a/client/src/components/allocations-assignment/allocations-assignment.component.jsx +++ b/client/src/components/allocations-assignment/allocations-assignment.component.jsx @@ -9,10 +9,7 @@ const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop }); -export default connect( - mapStateToProps, - null -)(function AllocationsAssignmentComponent({ +export function AllocationsAssignmentComponent({ bodyshop, handleAssignment, assignment, @@ -30,16 +27,15 @@ export default connect( const popContent = (
-