|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @emails oncall+react_native |
| 8 | + * @format |
| 9 | + */ |
| 10 | + |
| 11 | +/* global element, by, expect */ |
| 12 | + |
| 13 | +describe('DatePickerIOS', () => { |
| 14 | + beforeAll(async () => { |
| 15 | + await element(by.id('explorer_search')).replaceText('<DatePickerIOS>'); |
| 16 | + await element( |
| 17 | + by.label( |
| 18 | + '<DatePickerIOS> Select dates and times using the native UIDatePicker.', |
| 19 | + ), |
| 20 | + ).tap(); |
| 21 | + }); |
| 22 | + |
| 23 | + afterAll(async () => { |
| 24 | + await element(by.label('Back')).tap(); |
| 25 | + }); |
| 26 | + |
| 27 | + it('Should change indicator with datetime picker', async () => { |
| 28 | + const testID = 'date-and-time'; |
| 29 | + const indicatorID = 'date-and-time-indicator'; |
| 30 | + |
| 31 | + const testElement = await element( |
| 32 | + by.type('UIPickerView').withAncestor(by.id(testID)), |
| 33 | + ); |
| 34 | + const indicator = await element(by.id(indicatorID)); |
| 35 | + |
| 36 | + await expect(testElement).toBeVisible(); |
| 37 | + await expect(indicator).toBeVisible(); |
| 38 | + |
| 39 | + await testElement.setColumnToValue(0, 'Dec 4'); |
| 40 | + await testElement.setColumnToValue(1, '4'); |
| 41 | + await testElement.setColumnToValue(2, '10'); |
| 42 | + await testElement.setColumnToValue(3, 'AM'); |
| 43 | + |
| 44 | + await expect(indicator).toHaveText('12/4/2005 4:10 AM'); |
| 45 | + }); |
| 46 | + |
| 47 | + it('Should change indicator with date-only picker', async () => { |
| 48 | + const testID = 'date-only'; |
| 49 | + const indicatorID = 'date-and-time-indicator'; |
| 50 | + |
| 51 | + const testElement = await element( |
| 52 | + by.type('UIPickerView').withAncestor(by.id(testID)), |
| 53 | + ); |
| 54 | + const indicator = await element(by.id(indicatorID)); |
| 55 | + |
| 56 | + await expect(testElement).toBeVisible(); |
| 57 | + await expect(indicator).toBeVisible(); |
| 58 | + |
| 59 | + await testElement.setColumnToValue(0, 'November'); |
| 60 | + await testElement.setColumnToValue(1, '3'); |
| 61 | + await testElement.setColumnToValue(2, '2006'); |
| 62 | + |
| 63 | + await expect(indicator).toHaveText('11/3/2006 4:10 AM'); |
| 64 | + }); |
| 65 | +}); |
0 commit comments