Skip to content

Commit 9dfec66

Browse files
mendyEdriethanshar
andauthored
Picker multi select support - test fixed (#885)
* pass dialog events to picker custom model to support multi-selection * refactor code to make label text decision more intuitive * Made label source selection more intuitive * changed test uut function to match new logic -[failed tests] * fixed eslint issue Co-authored-by: Ethan Sharabi <[email protected]>
1 parent a84bdd5 commit 9dfec66

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/components/picker/__tests__/index.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ describe('Picker', () => {
1212
describe('getLabel', () => {
1313
it('should get label of a simple item', () => {
1414
let uut = new Picker({value: countries[2]});
15-
expect(uut.getLabel()).toEqual(countries[2].label);
15+
expect(uut.getLabelValueText()).toEqual(countries[2].label);
1616
uut = new Picker({value: countries[3]});
17-
expect(uut.getLabel()).toEqual(countries[3].label);
17+
expect(uut.getLabelValueText()).toEqual(countries[3].label);
1818
});
1919

2020
it('should get label out of an array of items', () => {
2121
const uut = new Picker({value: [countries[2], countries[4]]});
22-
expect(uut.getLabel()).toEqual(`${countries[2].label}, ${countries[4].label}`);
22+
expect(uut.getLabelValueText()).toEqual(`${countries[2].label}, ${countries[4].label}`);
2323
});
2424
});
2525

src/components/picker/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class Picker extends BaseComponent {
169169
getAccessibilityInfo() {
170170
const {placeholder} = this.props;
171171
return {
172-
accessibilityLabel: this.getLabel() ? `${placeholder}. selected. ${this.getLabel()}` : `Select ${placeholder}`,
173-
accessibilityHint: this.getLabel()
172+
accessibilityLabel: this.getLabelValueText() ? `${placeholder}. selected. ${this.getLabelValueText()}` : `Select ${placeholder}`,
173+
accessibilityHint: this.getLabelValueText()
174174
? 'Double tap to edit'
175175
: `Goes to ${placeholder}. Suggestions will be provided`,
176176
...this.extractAccessibilityProps()
@@ -224,7 +224,7 @@ class Picker extends BaseComponent {
224224
const {items} = this.state;
225225
const selectedItem = _.find(items, {value});
226226
return _.get(selectedItem, 'label');
227-
};
227+
}
228228

229229
handlePickerOnPress = () => {
230230
this.toggleExpandableModal(true);

0 commit comments

Comments
 (0)