Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lfkwtz committed Feb 14, 2019
1 parent 413b30b commit 76012af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export default class RNPickerSelect extends PureComponent {
>
<TouchableOpacity
style={[defaultStyles.modalViewTop, style.modalViewTop]}
testID="ios_modal_top"
onPress={() => {
this.togglePicker(true);
}}
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ describe('RNPickerSelect', () => {
expect(onCloseSpy).toHaveBeenCalledWith();
});

it('should close the modal when the empty area above the picker is tapped', () => {
const wrapper = shallow(<RNPickerSelect items={selectItems} onValueChange={() => {}} />);

jest.spyOn(wrapper.instance(), 'togglePicker');

const touchable = wrapper.find('[testID="ios_modal_top"]');
touchable.simulate('press');

expect(wrapper.instance().togglePicker).toHaveBeenCalledWith(true);
});

describe('getDerivedStateFromProps', () => {
it('should return null when nothing changes', () => {
const nextProps = {
Expand Down

0 comments on commit 76012af

Please sign in to comment.