Skip to content

Commit 8be9c8f

Browse files
committed
test: update accessibility tests to expect pickerProps.accessibilityLabel
1 parent cb7cd29 commit 8be9c8f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/test.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,51 +415,55 @@ describe('RNPickerSelect', () => {
415415
items={selectItems}
416416
onValueChange={noop}
417417
useNativeAndroidPickerStyle={false}
418+
pickerProps={{
419+
accessibilityLabel: 'Select an item',
420+
}}
418421
/>
419422
);
420423

421424
const touchable = wrapper.find('[testID="android_touchable_wrapper"]');
422425

423426
expect(touchable.props().accessible).toEqual(true);
424427
expect(touchable.props().accessibilityRole).toEqual('combobox');
425-
// Default placeholder label is "Select an item..."
426-
expect(touchable.props().accessibilityLabel).toEqual('Select an item...');
428+
expect(touchable.props().accessibilityLabel).toEqual('Select an item');
427429
expect(touchable.props().accessibilityState).toEqual({ disabled: false });
428430
expect(touchable.props().accessibilityActions).toEqual([{ name: 'activate' }]);
429431
expect(touchable.props().onAccessibilityAction).toBeDefined();
430432
});
431433

432-
it('should use selectedItem label as accessibilityLabel (Android headless)', () => {
434+
it('should use accessibilityLabel from pickerProps (Android headless)', () => {
433435
const wrapper = shallow(
434436
<RNPickerSelect
435437
items={selectItems}
436438
placeholder={{}}
437439
onValueChange={noop}
438440
useNativeAndroidPickerStyle={false}
439441
value="orange"
442+
pickerProps={{
443+
accessibilityLabel: 'Choose a color',
444+
}}
440445
/>
441446
);
442447

443448
const touchable = wrapper.find('[testID="android_touchable_wrapper"]');
444449

445-
expect(touchable.props().accessibilityLabel).toEqual('Orange');
450+
expect(touchable.props().accessibilityLabel).toEqual('Choose a color');
446451
});
447452

448-
it('should use inputLabel as accessibilityLabel when provided (Android headless)', () => {
449-
const itemsWithInputLabel = [{ label: 'Red', value: 'red', inputLabel: 'RED COLOR' }];
453+
it('should have undefined accessibilityLabel when not provided via pickerProps (Android headless)', () => {
450454
const wrapper = shallow(
451455
<RNPickerSelect
452-
items={itemsWithInputLabel}
456+
items={selectItems}
453457
placeholder={{}}
454458
onValueChange={noop}
455459
useNativeAndroidPickerStyle={false}
456-
value="red"
460+
value="orange"
457461
/>
458462
);
459463

460464
const touchable = wrapper.find('[testID="android_touchable_wrapper"]');
461465

462-
expect(touchable.props().accessibilityLabel).toEqual('RED COLOR');
466+
expect(touchable.props().accessibilityLabel).toBeUndefined();
463467
});
464468

465469
it('should have importantForAccessibility on inner container (Android headless)', () => {

0 commit comments

Comments
 (0)