-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a470d79
commit a08028e
Showing
4 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
frontend/front/src/components/SurveyComponent/__tests__/HeatPumpDropdown.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<HeatPumpDropdown | ||
key={`q${q.id}`} | ||
control={control} | ||
name={`${q.id}`} | ||
label={q.text} | ||
options={q.response_options.map((o) => ({ | ||
value: o, | ||
label: o, | ||
}))} | ||
/> | ||
); | ||
}; | ||
|
||
describe("HeatPumpDropdown", () => { | ||
it("renders as expected", () => { | ||
const { container } = render(<FormWrapper q={YES_NO_FIELD} />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
...ront/src/components/SurveyComponent/__tests__/__snapshots__/HeatPumpDropdown.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`HeatPumpDropdown renders as expected 1`] = ` | ||
<div> | ||
<div | ||
class="MuiFormControl-root MuiFormControl-fullWidth css-q8hpuo-MuiFormControl-root" | ||
> | ||
<label | ||
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined css-14s5rfu-MuiFormLabel-root-MuiInputLabel-root" | ||
data-shrink="false" | ||
id="1-dropdown-label" | ||
> | ||
Have you heard of heat pumps? | ||
</label> | ||
<div | ||
aria-labelledby="1-dropdown-label" | ||
class="MuiInputBase-root MuiFilledInput-root MuiFilledInput-underline MuiInputBase-colorPrimary MuiInputBase-formControl css-llrb4p-MuiInputBase-root-MuiFilledInput-root-MuiSelect-root" | ||
> | ||
<div | ||
aria-expanded="false" | ||
aria-haspopup="listbox" | ||
aria-labelledby="mui-component-select-1" | ||
class="MuiSelect-select MuiSelect-filled MuiInputBase-input MuiFilledInput-input css-d9oaum-MuiSelect-select-MuiInputBase-input-MuiFilledInput-input" | ||
id="mui-component-select-1" | ||
role="button" | ||
tabindex="0" | ||
> | ||
<span | ||
class="notranslate" | ||
> | ||
| ||
</span> | ||
</div> | ||
<input | ||
aria-hidden="true" | ||
aria-invalid="false" | ||
class="MuiSelect-nativeInput css-yf8vq0-MuiSelect-nativeInput" | ||
name="1" | ||
tabindex="-1" | ||
value="" | ||
/> | ||
<svg | ||
aria-hidden="true" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiSelect-icon MuiSelect-iconFilled css-hfutr2-MuiSvgIcon-root-MuiSelect-icon" | ||
data-testid="ArrowDropDownIcon" | ||
focusable="false" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
d="M7 10l5 5 5-5z" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters