-
Notifications
You must be signed in to change notification settings - Fork 0
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
864f52a
commit c3eb901
Showing
5 changed files
with
225 additions
and
19 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
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
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 { cleanup, fireEvent, render, wait } from "@testing-library/react"; | ||
import * as React from "react"; | ||
|
||
import Checkboxes from "../Checkboxes"; | ||
|
||
afterEach(cleanup); | ||
|
||
/* TO DO | ||
1 - Add test for the success scenario when form submits and there is a success message | ||
2- Add test for the fail scenario when the form doesn't submit and thee is an error message | ||
*/ | ||
|
||
describe("Checkboxes Component", () => { | ||
it("should render items correctly", async () => { | ||
const title = "test title"; | ||
const name = "test name"; | ||
const options = {}; | ||
const { findByText } = render( | ||
<Checkboxes title={title} options={options} name={name} /> | ||
); | ||
expect(await findByText(/test title/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it("should render snapshot", () => { | ||
const title = "test title"; | ||
const name = "test name"; | ||
const options = { | ||
oak: "option 1", | ||
plane: "option 2", | ||
redwood: "option 3", | ||
other: "option 4" | ||
}; | ||
const { asFragment } = render( | ||
<Checkboxes title={title} options={options} name={name} /> | ||
); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
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
168 changes: 168 additions & 0 deletions
168
src/components/__tests__/__snapshots__/Checkboxes.tsx.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,168 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Checkboxes Component should render snapshot 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="MuiBox-root MuiBox-root-96" | ||
> | ||
<form> | ||
<h5 | ||
class="MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom" | ||
> | ||
test title | ||
</h5> | ||
<fieldset | ||
class="MuiFormControl-root" | ||
> | ||
<legend | ||
class="MuiFormLabel-root makeStyles-formControlLabelRoot-93" | ||
> | ||
<div | ||
class="MuiBox-root MuiBox-root-139" | ||
> | ||
Select all that apply | ||
</div> | ||
</legend> | ||
<div | ||
class="MuiBox-root MuiBox-root-140" | ||
> | ||
<div | ||
class="MuiFormGroup-root" | ||
> | ||
<label | ||
class="MuiFormControlLabel-root makeStyles-formControlLabelRoot-93" | ||
> | ||
<span | ||
aria-disabled="false" | ||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-158 MuiCheckbox-root makeStyles-checkBoxRoot-149 MuiCheckbox-colorSecondary MuiIconButton-colorSecondary" | ||
> | ||
<span | ||
class="MuiIconButton-label" | ||
> | ||
<input | ||
class="PrivateSwitchBase-input-161" | ||
data-indeterminate="false" | ||
name="oak" | ||
type="checkbox" | ||
value="oak" | ||
/> | ||
<span | ||
class="makeStyles-icon-150" | ||
font-size="default" | ||
/> | ||
</span> | ||
</span> | ||
<span | ||
class="MuiTypography-root MuiFormControlLabel-label makeStyles-formControlLabel-94 MuiTypography-body1" | ||
> | ||
option 1 | ||
</span> | ||
</label> | ||
<label | ||
class="MuiFormControlLabel-root makeStyles-formControlLabelRoot-93" | ||
> | ||
<span | ||
aria-disabled="false" | ||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-158 MuiCheckbox-root makeStyles-checkBoxRoot-149 MuiCheckbox-colorSecondary MuiIconButton-colorSecondary" | ||
> | ||
<span | ||
class="MuiIconButton-label" | ||
> | ||
<input | ||
class="PrivateSwitchBase-input-161" | ||
data-indeterminate="false" | ||
name="plane" | ||
type="checkbox" | ||
value="plane" | ||
/> | ||
<span | ||
class="makeStyles-icon-150" | ||
font-size="default" | ||
/> | ||
</span> | ||
</span> | ||
<span | ||
class="MuiTypography-root MuiFormControlLabel-label makeStyles-formControlLabel-94 MuiTypography-body1" | ||
> | ||
option 2 | ||
</span> | ||
</label> | ||
<label | ||
class="MuiFormControlLabel-root makeStyles-formControlLabelRoot-93" | ||
> | ||
<span | ||
aria-disabled="false" | ||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-158 MuiCheckbox-root makeStyles-checkBoxRoot-149 MuiCheckbox-colorSecondary MuiIconButton-colorSecondary" | ||
> | ||
<span | ||
class="MuiIconButton-label" | ||
> | ||
<input | ||
class="PrivateSwitchBase-input-161" | ||
data-indeterminate="false" | ||
name="redwood" | ||
type="checkbox" | ||
value="redwood" | ||
/> | ||
<span | ||
class="makeStyles-icon-150" | ||
font-size="default" | ||
/> | ||
</span> | ||
</span> | ||
<span | ||
class="MuiTypography-root MuiFormControlLabel-label makeStyles-formControlLabel-94 MuiTypography-body1" | ||
> | ||
option 3 | ||
</span> | ||
</label> | ||
<label | ||
class="MuiFormControlLabel-root makeStyles-formControlLabelRoot-93" | ||
> | ||
<span | ||
aria-disabled="false" | ||
class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-158 MuiCheckbox-root makeStyles-checkBoxRoot-149 MuiCheckbox-colorSecondary MuiIconButton-colorSecondary" | ||
> | ||
<span | ||
class="MuiIconButton-label" | ||
> | ||
<input | ||
class="PrivateSwitchBase-input-161" | ||
data-indeterminate="false" | ||
name="other" | ||
type="checkbox" | ||
value="other" | ||
/> | ||
<span | ||
class="makeStyles-icon-150" | ||
font-size="default" | ||
/> | ||
</span> | ||
</span> | ||
<span | ||
class="MuiTypography-root MuiFormControlLabel-label makeStyles-formControlLabel-94 MuiTypography-body1" | ||
> | ||
option 4 | ||
</span> | ||
</label> | ||
</div> | ||
</div> | ||
<button | ||
class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary" | ||
tabindex="0" | ||
type="submit" | ||
> | ||
<span | ||
class="MuiButton-label" | ||
> | ||
Save and Continue | ||
</span> | ||
<span | ||
class="MuiTouchRipple-root" | ||
/> | ||
</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</DocumentFragment> | ||
`; |