From a08028eaa85e971c5338f4897948d1f9cae42d88 Mon Sep 17 00:00:00 2001 From: Matt DelSordo Date: Mon, 25 Sep 2023 19:01:27 -0400 Subject: [PATCH] fix tests --- frontend/front/README.md | 3 +- .../__tests__/HeatPumpDropdown.test.js | 38 +++++++++++++ .../HeatPumpDropdown.test.js.snap | 56 +++++++++++++++++++ frontend/front/yarn.lock | 48 +++++++++++++++- 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 frontend/front/src/components/SurveyComponent/__tests__/HeatPumpDropdown.test.js create mode 100644 frontend/front/src/components/SurveyComponent/__tests__/__snapshots__/HeatPumpDropdown.test.js.snap diff --git a/frontend/front/README.md b/frontend/front/README.md index ac88bee5..4b728a33 100644 --- a/frontend/front/README.md +++ b/frontend/front/README.md @@ -60,13 +60,14 @@ We also have a dummy json-server located at `/frontend/jsonserver`. However, it' 10. Make sure to copy the pull request link and paste into the frontend slack page so that folks notice. 11. After your pull request is approved, you can merge it and close any github issue related to the pull request. - ## Building Docker Image for Mass Open Cloud + Assuming you are pushing to the Docker registry for mzagaja, you should do: ```sh docker build --platform linux/amd64 --build-arg REACT_APP_API_URL=http://api.bostonhpa.org -t mzagaja/bhpa-frontend:latest --push . ``` + --- # Getting Started with Create React App diff --git a/frontend/front/src/components/SurveyComponent/__tests__/HeatPumpDropdown.test.js b/frontend/front/src/components/SurveyComponent/__tests__/HeatPumpDropdown.test.js new file mode 100644 index 00000000..dd64d335 --- /dev/null +++ b/frontend/front/src/components/SurveyComponent/__tests__/HeatPumpDropdown.test.js @@ -0,0 +1,38 @@ +import { render } from "@testing-library/react"; +import React from "react"; +import { HeatPumpDropdown } from "../HeatPumpDropdown"; +import { useForm } from "react-hook-form"; + +const YES_NO_FIELD = { + id: 1, + display_order: 1, + text: "Have you heard of heat pumps?", + response_type: "radio", + response_options: ["Yes", "No"], +}; + +const DEFAULT_FORM = { 1: "" }; + +const FormWrapper = ({ q }) => { + const { control } = useForm({ defaultValues: DEFAULT_FORM }); + return ( + ({ + value: o, + label: o, + }))} + /> + ); +}; + +describe("HeatPumpDropdown", () => { + it("renders as expected", () => { + const { container } = render(); + + expect(container).toMatchSnapshot(); + }); +}); diff --git a/frontend/front/src/components/SurveyComponent/__tests__/__snapshots__/HeatPumpDropdown.test.js.snap b/frontend/front/src/components/SurveyComponent/__tests__/__snapshots__/HeatPumpDropdown.test.js.snap new file mode 100644 index 00000000..0906ac92 --- /dev/null +++ b/frontend/front/src/components/SurveyComponent/__tests__/__snapshots__/HeatPumpDropdown.test.js.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`HeatPumpDropdown renders as expected 1`] = ` +
+
+ +
+ + + +
+
+
+`; diff --git a/frontend/front/yarn.lock b/frontend/front/yarn.lock index 8d0860ab..3f38c4b9 100644 --- a/frontend/front/yarn.lock +++ b/frontend/front/yarn.lock @@ -87,7 +87,7 @@ "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" -"@babel/helper-annotate-as-pure@^7.22.5": +"@babel/helper-annotate-as-pure@^7.18.6", "@babel/helper-annotate-as-pure@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.22.5.tgz#e7f06737b197d580a01edf75d97e2c8be99d3882" integrity sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg== @@ -127,6 +127,21 @@ "@babel/helper-split-export-declaration" "^7.22.6" semver "^6.3.1" +"@babel/helper-create-class-features-plugin@^7.21.0": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.15.tgz#97a61b385e57fe458496fad19f8e63b63c867de4" + integrity sha512-jKkwA59IXcvSaiK2UN45kKwSC9o+KuoXsBDvHvU/7BecYIp8GQ2UwrVvFgJASUT+hBnwJx6MhvMCuMzwZZ7jlg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-environment-visitor" "^7.22.5" + "@babel/helper-function-name" "^7.22.5" + "@babel/helper-member-expression-to-functions" "^7.22.15" + "@babel/helper-optimise-call-expression" "^7.22.5" + "@babel/helper-replace-supers" "^7.22.9" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + semver "^6.3.1" + "@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.22.5": version "7.22.9" resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.22.9.tgz#9d8e61a8d9366fe66198f57c40565663de0825f6" @@ -167,6 +182,13 @@ dependencies: "@babel/types" "^7.22.5" +"@babel/helper-member-expression-to-functions@^7.22.15": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.23.0.tgz#9263e88cc5e41d39ec18c9a3e0eced59a3e7d366" + integrity sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA== + dependencies: + "@babel/types" "^7.23.0" + "@babel/helper-member-expression-to-functions@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.22.5.tgz#0a7c56117cad3372fbf8d2fb4bf8f8d64a1e76b2" @@ -248,6 +270,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz#533f36457a25814cf1df6488523ad547d784a99f" integrity sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw== +"@babel/helper-validator-identifier@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" + integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== + "@babel/helper-validator-identifier@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193" @@ -363,6 +390,16 @@ resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz#7844f9289546efa9febac2de4cfe358a050bd703" integrity sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w== +"@babel/plugin-proposal-private-property-in-object@^7.21.11": + version "7.21.11" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz#69d597086b6760c4126525cfa154f34631ff272c" + integrity sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-create-class-features-plugin" "^7.21.0" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" @@ -1147,6 +1184,15 @@ "@babel/helper-validator-identifier" "^7.22.5" to-fast-properties "^2.0.0" +"@babel/types@^7.23.0": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.0.tgz#8c1f020c9df0e737e4e247c0619f58c68458aaeb" + integrity sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg== + dependencies: + "@babel/helper-string-parser" "^7.22.5" + "@babel/helper-validator-identifier" "^7.22.20" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"