From 10d85bcf46a6399f270f55c8657cc671fcb5af25 Mon Sep 17 00:00:00 2001 From: ErnestoEsp Date: Tue, 27 Sep 2022 13:47:28 +0200 Subject: [PATCH] Hot fix test --- __tests__/components/CheckBox.test.tsx | 42 +++++++++++++------ .../components/ConfirmationDialog.test.tsx | 42 ++++++++----------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/__tests__/components/CheckBox.test.tsx b/__tests__/components/CheckBox.test.tsx index 92a2217..26952e4 100644 --- a/__tests__/components/CheckBox.test.tsx +++ b/__tests__/components/CheckBox.test.tsx @@ -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() +it('Should renders correctly', () => { + const { getByText } = render( + + ) const checkBoxText = getByText('Accept terms and conditions') expect(checkBoxText).toBeTruthy() }) -it("Should open modal when checkbox label is clicked", () => { - const { getByText } = render() +it('Should open modal when checkbox label is clicked', () => { + const { getByText } = render( + + ) const checkBoxText = getByText('Accept terms and conditions') fireEvent.press(checkBoxText) expect(mockedOpenModal.openModal).toHaveBeenCalled() }) - diff --git a/__tests__/components/ConfirmationDialog.test.tsx b/__tests__/components/ConfirmationDialog.test.tsx index bc7b49e..29378f3 100644 --- a/__tests__/components/ConfirmationDialog.test.tsx +++ b/__tests__/components/ConfirmationDialog.test.tsx @@ -1,8 +1,7 @@ -import { fireEvent, render } from "@testing-library/react-native" -import React from "react" - -import ConfirmationDialog from "../../src/components/ConfirmationDialog" +import { fireEvent, render } from '@testing-library/react-native' +import React from 'react' +import ConfirmationDialog from '../../src/components/ConfirmationDialog' jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper') @@ -10,7 +9,7 @@ const mockedState = { visible: true, message: '', cancelPress: jest.fn, - onPress: jest.fn + onPress: jest.fn, } const mockedNavigate = jest.fn() @@ -36,49 +35,42 @@ jest.mock('react-native-paper', () => { }) it('Should shows a dialog and cancel/continue buttons', () => { - const { getByText, getByRole, getByTestId } = render( + const { getByText, getByRole, getByTestId } = render( + ) - const dialog = getByText('Confirm transaction:') + const dialog = getByText('Confirm:') const cancelButton = getByTestId('cancel') const continueButton = getByTestId('continue') expect(dialog).toBeTruthy() expect(cancelButton).toBeTruthy() expect(continueButton).toBeTruthy() - }) it('Should do nothing and navigate to dashboard screen', () => { - const { getByTestId } = render( + const { getByTestId } = render( + ) const cancelButton = getByTestId('cancel') fireEvent.press(cancelButton) expect(mockedNavigate).toHaveBeenCalled() - }) it('Should execute transaction and navigate to dashboard screen', () => { - const { getByTestId } = render() + const { getByTestId } = render( + + ) const continueButton = getByTestId('continue') fireEvent.press(continueButton) expect(mockedNavigate).toHaveBeenCalled() - }) -