diff --git a/app/components/nDilation/Calculator.jsx b/app/components/nDilation/Calculator.jsx index c6560bc..6036802 100644 --- a/app/components/nDilation/Calculator.jsx +++ b/app/components/nDilation/Calculator.jsx @@ -2,7 +2,7 @@ import React, { useReducer } from "react"; import fetchNDilation from "../../lib/fetchNDilation"; import { useWindowContext } from "../WindowContext"; -import MatrixInput from "./MatrixInput"; +import DilationForm from "./DilationForm"; import Result from "./Result"; const initialState = { isLoading: false, dilation: null, error: null }; @@ -48,7 +48,7 @@ const Calculator = () => { return (
- number > 0 && Math.sqrt(number) % 1 === 0; -const MatrixInput = ({ onSubmit }) => { +const DilationForm = ({ onSubmit }) => { const [input, setInput] = useState(""); const [degree, setDegree] = useState(2); @@ -117,4 +117,4 @@ const MatrixInput = ({ onSubmit }) => { ); }; -export default MatrixInput; +export default DilationForm; diff --git a/app/components/nDilation/test/Calculator.test.jsx b/app/components/nDilation/test/Calculator.test.jsx index 18f0469..2c01c3f 100644 --- a/app/components/nDilation/test/Calculator.test.jsx +++ b/app/components/nDilation/test/Calculator.test.jsx @@ -1,7 +1,7 @@ import React from "react"; import { shallow } from "enzyme"; -import MatrixInput from "../MatrixInput"; +import DilationForm from "../DilationForm"; import Result from "../Result"; import * as WindowContext from "../../WindowContext"; import Calculator from "../Calculator"; @@ -33,11 +33,11 @@ describe("Calculator", () => { }); describe("on client", () => { - it("call fetch when onSubmit on MatrixInput is called", async () => { + it("call fetch when onSubmit on DilationForm is called", async () => { const window = createWindow(); const component = render(window); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); expect(window.fetch.mock.calls.length).toEqual(1); }); @@ -57,7 +57,7 @@ describe("Calculator", () => { expect(component.find(Result).prop("isLoading")).toEqual(false); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); expect(component.find(Result).prop("isLoading")).toEqual(false); }); @@ -69,7 +69,7 @@ describe("Calculator", () => { json: () => Promise.resolve({ value: dilation }), }; const component = render(createWindow(response)); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); expect(component.find(Result).prop("dilation")).toEqual(dilation); }); @@ -85,7 +85,7 @@ describe("Calculator", () => { json: () => Promise.resolve(responseBody), }; const component = render(createWindow(response)); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); expect(component.find(Result).prop("errorDetails")).toEqual( responseBody ); @@ -95,7 +95,7 @@ describe("Calculator", () => { const error = new Error("Mock Error"); const fetch = jest.fn(() => Promise.reject(error)); const component = render(createWindow(null, fetch)); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); expect(component.find(Result).prop("errorDetails")).toEqual( error ); @@ -104,12 +104,12 @@ describe("Calculator", () => { it("and not render dilation from a first fetch if a second fetch throws", async () => { const window = createWindow(); const component = render(window); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); const mockError = new Error("Mock Error"); window.fetch.mockImplementation(() => Promise.reject(mockError) ); - await component.find(MatrixInput).prop("onSubmit")(); + await component.find(DilationForm).prop("onSubmit")(); const result = component.find(Result); expect(result.prop("dilation")).toBe(null); expect(result.prop("errorDetails")).toEqual(mockError); diff --git a/app/components/nDilation/test/MatrixInput.test.jsx b/app/components/nDilation/test/DilationForm.test.jsx similarity index 95% rename from app/components/nDilation/test/MatrixInput.test.jsx rename to app/components/nDilation/test/DilationForm.test.jsx index ad5c3bb..0884210 100644 --- a/app/components/nDilation/test/MatrixInput.test.jsx +++ b/app/components/nDilation/test/DilationForm.test.jsx @@ -2,7 +2,7 @@ import React from "react"; import { shallow } from "enzyme"; import TextAreaAutosize from "react-textarea-autosize"; -import MatrixInput from "../MatrixInput"; +import DilationForm from "../DilationForm"; const defaultSubmitEvent = { preventDefault: () => {}, @@ -12,9 +12,9 @@ const defaultProps = { onSubmit: jest.fn(), }; -const render = () => shallow(); +const render = () => shallow(); -describe("MatrixInput", () => { +describe("DilationForm", () => { it("should render a form", () => { const component = render(); diff --git a/app/components/nDilation/test/__snapshots__/Calculator.test.jsx.snap b/app/components/nDilation/test/__snapshots__/Calculator.test.jsx.snap index 420c552..5f57196 100644 --- a/app/components/nDilation/test/__snapshots__/Calculator.test.jsx.snap +++ b/app/components/nDilation/test/__snapshots__/Calculator.test.jsx.snap @@ -2,7 +2,7 @@ exports[`Calculator should render 1`] = `
-