-
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
ErnestoEsp
committed
Sep 27, 2022
1 parent
336805a
commit 10d85bc
Showing
2 changed files
with
47 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,47 @@ | ||
import { fireEvent, render } from "@testing-library/react-native" | ||
import React from "react" | ||
import CheckBox from "../../src/components/CheckBox" | ||
import { fireEvent, render } from '@testing-library/react-native' | ||
import React from 'react' | ||
import CheckBox from '../../src/components/CheckBox' | ||
|
||
const mockedOpenModal = { | ||
openModal: jest.fn(), | ||
} | ||
const mockedCheckBox = { | ||
checkBox: jest.fn(), | ||
} | ||
|
||
it("Should renders correctly", () => { | ||
const { getByText } = render(<CheckBox onPress={function (): void { | ||
throw new Error("Function not implemented.") | ||
}} status={"checked"} />) | ||
it('Should renders correctly', () => { | ||
const { getByText } = render( | ||
<CheckBox | ||
onPressText={function (): void { | ||
throw new Error('Function not implemented.') | ||
}} | ||
status={'checked'} | ||
onCheck={function (): void { | ||
mockedCheckBox.checkBox() | ||
}} | ||
/> | ||
) | ||
|
||
const checkBoxText = getByText('Accept terms and conditions') | ||
|
||
expect(checkBoxText).toBeTruthy() | ||
}) | ||
|
||
it("Should open modal when checkbox label is clicked", () => { | ||
const { getByText } = render(<CheckBox onPress={function (): void { | ||
mockedOpenModal.openModal() | ||
}} status={"checked"} />) | ||
it('Should open modal when checkbox label is clicked', () => { | ||
const { getByText } = render( | ||
<CheckBox | ||
onPressText={function (): void { | ||
mockedOpenModal.openModal() | ||
}} | ||
status={'checked'} | ||
onCheck={function (): void { | ||
mockedCheckBox.checkBox() | ||
}} | ||
/> | ||
) | ||
|
||
const checkBoxText = getByText('Accept terms and conditions') | ||
fireEvent.press(checkBoxText) | ||
|
||
expect(mockedOpenModal.openModal).toHaveBeenCalled() | ||
}) | ||
|
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