diff --git a/app/containers/SearchBox/SearchBox.test.tsx b/app/containers/SearchBox/SearchBox.test.tsx
index 6ca161d36..c1317df6a 100644
--- a/app/containers/SearchBox/SearchBox.test.tsx
+++ b/app/containers/SearchBox/SearchBox.test.tsx
@@ -1,6 +1,5 @@
import React from 'react';
import { fireEvent, render } from '@testing-library/react-native';
-import { TextInputProps } from 'react-native';
import SearchBox from '.';
@@ -11,35 +10,35 @@ const testSearchInputs = {
testID: 'search-box-text-input'
};
-const Render = ({ onChangeText, testID }: TextInputProps) => ;
-
describe('SearchBox', () => {
it('should render the searchbox component', () => {
- const { findByTestId } = render();
+ const { findByTestId } = render();
expect(findByTestId('searchbox')).toBeTruthy();
});
+
it('should not render clear-input icon', async () => {
- const { queryByTestId } = render();
+ const { queryByTestId } = render();
const clearInput = await queryByTestId('clear-text-input');
expect(clearInput).toBeNull();
});
it('should input new value with onChangeText function', async () => {
- const { findByTestId } = render();
+ const { findByTestId } = render();
const component = await findByTestId(testSearchInputs.testID);
fireEvent.changeText(component, 'new-input-value');
expect(onChangeTextMock).toHaveBeenCalledWith('new-input-value');
});
- // we need skip this test for now, until discovery how handle with functions effect
- // https://github.com/callstack/react-native-testing-library/issues/978
- it.skip('should clear input when call onCancelSearch function', async () => {
- const { findByTestId } = render();
+ it('should clear input when clear icon is pressed', async () => {
+ const { findByTestId } = render();
- const component = await findByTestId('clear-text-input');
- fireEvent.press(component, 'input-with-value');
- expect(onChangeTextMock).toHaveBeenCalledWith('input-with-value');
+ const component = await findByTestId(testSearchInputs.testID);
+ fireEvent.changeText(component, 'new-input-value');
+
+ const clearTextInput = await findByTestId('clear-text-input');
+ fireEvent.press(clearTextInput);
+ expect(onChangeTextMock).toHaveBeenCalledWith('');
});
});