Skip to content

Commit

Permalink
#161 supports empty items arr (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfkwtz authored Jun 11, 2019
1 parent fbe828b commit 3a6730d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 6.2.0

##### New

- Supports an empty `items` array (#161)

---

### 6.1.1

##### Bugfix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-picker-select",
"version": "6.1.1",
"version": "6.2.0",
"description": "A Picker component for React Native which emulates the native <select> interfaces for each platform",
"license": "MIT",
"author": "Michael Lefkowitz <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class RNPickerSelect extends PureComponent {
idx = 0;
}
return {
selectedItem: items[idx],
selectedItem: items[idx] || {},
idx,
};
}
Expand Down
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ describe('RNPickerSelect', () => {
expect(done_bar).toHaveLength(0);
});

it('should handle an empty items array', () => {
const wrapper = shallow(
<RNPickerSelect items={[]} placeholder={{}} onValueChange={() => {}} />
);

expect(wrapper.state().items).toHaveLength(0);
});

it('should return the expected option to a callback passed into onSelect', () => {
const onValueChangeSpy = jest.fn();
const wrapper = shallow(
Expand Down

0 comments on commit 3a6730d

Please sign in to comment.