diff --git a/RNTester/e2e/__tests__/Button-test.js b/RNTester/e2e/__tests__/Button-test.js index 5a4bf7fd9f4a..3ac9b7e65e9e 100644 --- a/RNTester/e2e/__tests__/Button-test.js +++ b/RNTester/e2e/__tests__/Button-test.js @@ -25,18 +25,27 @@ describe('Button', () => { }); it('Simple button should be tappable', async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Simple Button', + ); await element(by.id('simple_button')).tap(); await expect(element(by.text('Simple has been pressed!'))).toBeVisible(); await element(by.text('OK')).tap(); }); it('Adjusted color button should be tappable', async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Adjusted color', + ); await element(by.id('purple_button')).tap(); await expect(element(by.text('Purple has been pressed!'))).toBeVisible(); await element(by.text('OK')).tap(); }); it("Two buttons with JustifyContent:'space-between' should be tappable", async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Fit to text layout', + ); await element(by.id('left_button')).tap(); await expect(element(by.text('Left has been pressed!'))).toBeVisible(); await element(by.text('OK')).tap(); @@ -47,6 +56,9 @@ describe('Button', () => { }); it('Disabled button should not interact', async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Disabled Button', + ); await element(by.id('disabled_button')).tap(); await expect( element(by.text('Disabled has been pressed!')), diff --git a/RNTester/e2e/__tests__/DatePickerIOS-test.js b/RNTester/e2e/__tests__/DatePickerIOS-test.js index 0947e00c0a09..5752132e4cf3 100644 --- a/RNTester/e2e/__tests__/DatePickerIOS-test.js +++ b/RNTester/e2e/__tests__/DatePickerIOS-test.js @@ -25,6 +25,9 @@ describe('DatePickerIOS', () => { }); it('Should change indicator with datetime picker', async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Date and time picker', + ); const testID = 'date-and-time'; const indicatorID = 'date-and-time-indicator'; @@ -45,6 +48,7 @@ describe('DatePickerIOS', () => { }); it('Should change indicator with date-only picker', async () => { + await element(by.id('explorer_example_search')).replaceText('Date only'); const testID = 'date-only'; const indicatorID = 'date-and-time-indicator'; diff --git a/RNTester/e2e/__tests__/Picker-test.js b/RNTester/e2e/__tests__/Picker-test.js index 37a97ae49498..cf2bcb1ffeae 100644 --- a/RNTester/e2e/__tests__/Picker-test.js +++ b/RNTester/e2e/__tests__/Picker-test.js @@ -25,6 +25,7 @@ describe('Picker', () => { }); it('should be selectable by ID', async () => { + await element(by.id('explorer_example_search')).replaceText('Basic picker'); await expect(element(by.id('basic-picker'))).toBeVisible(); }); }); diff --git a/RNTester/e2e/__tests__/Switch-test.js b/RNTester/e2e/__tests__/Switch-test.js index c1d819d3023b..5af87cfe5995 100644 --- a/RNTester/e2e/__tests__/Switch-test.js +++ b/RNTester/e2e/__tests__/Switch-test.js @@ -19,63 +19,79 @@ describe('Switch', () => { await element(by.label(' Native boolean input')).tap(); }); - it('Switch that starts off should switch', async () => { - const testID = 'on-off-initial-off'; - const indicatorID = 'on-off-initial-off-indicator'; + describe('Switches can be set to true or false', () => { + beforeEach(async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Switches can be set to true or false', + ); + }); - await expect(element(by.id(testID))).toHaveValue('0'); - await expect(element(by.id(indicatorID))).toHaveText('Off'); - await element(by.id(testID)).tap(); - await expect(element(by.id(testID))).toHaveValue('1'); - await expect(element(by.id(indicatorID))).toHaveText('On'); - }); + it('Switch that starts off should switch', async () => { + const testID = 'on-off-initial-off'; + const indicatorID = 'on-off-initial-off-indicator'; - it('Switch that starts on should switch', async () => { - const testID = 'on-off-initial-on'; - const indicatorID = 'on-off-initial-on-indicator'; + await expect(element(by.id(testID))).toHaveValue('0'); + await expect(element(by.id(indicatorID))).toHaveText('Off'); + await element(by.id(testID)).tap(); + await expect(element(by.id(testID))).toHaveValue('1'); + await expect(element(by.id(indicatorID))).toHaveText('On'); + }); - await expect(element(by.id(testID))).toHaveValue('1'); - await expect(element(by.id(indicatorID))).toHaveText('On'); - await element(by.id(testID)).tap(); - await expect(element(by.id(testID))).toHaveValue('0'); - await expect(element(by.id(indicatorID))).toHaveText('Off'); + it('Switch that starts on should switch', async () => { + const testID = 'on-off-initial-on'; + const indicatorID = 'on-off-initial-on-indicator'; + + await expect(element(by.id(testID))).toHaveValue('1'); + await expect(element(by.id(indicatorID))).toHaveText('On'); + await element(by.id(testID)).tap(); + await expect(element(by.id(testID))).toHaveValue('0'); + await expect(element(by.id(indicatorID))).toHaveText('Off'); + }); }); - it('disabled switch should not toggle', async () => { - const onTestID = 'disabled-initial-on'; - const offTestID = 'disabled-initial-off'; - const onIndicatorID = 'disabled-initial-on-indicator'; - const offIndicatorID = 'disabled-initial-off-indicator'; + describe('Switches can be disabled', () => { + beforeEach(async () => { + await element(by.id('explorer_example_search')).replaceText( + 'Switches can be disabled', + ); + }); - await expect(element(by.id(onTestID))).toHaveValue('1'); - await expect(element(by.id(onIndicatorID))).toHaveText('On'); + it('disabled switch should not toggle', async () => { + const onTestID = 'disabled-initial-on'; + const offTestID = 'disabled-initial-off'; + const onIndicatorID = 'disabled-initial-on-indicator'; + const offIndicatorID = 'disabled-initial-off-indicator'; - try { - await element(by.id(onTestID)).tap(); - throw new Error('Does not match'); - } catch (err) { - jestExpect(err.message.message).toEqual( - jestExpect.stringContaining( - 'Cannot perform action due to constraint(s) failure', - ), - ); - } - await expect(element(by.id(onTestID))).toHaveValue('1'); - await expect(element(by.id(onIndicatorID))).toHaveText('On'); + await expect(element(by.id(onTestID))).toHaveValue('1'); + await expect(element(by.id(onIndicatorID))).toHaveText('On'); - await expect(element(by.id(offTestID))).toHaveValue('0'); - await expect(element(by.id(offIndicatorID))).toHaveText('Off'); - try { - await element(by.id(offTestID)).tap(); - throw new Error('Does not match'); - } catch (err) { - jestExpect(err.message.message).toEqual( - jestExpect.stringContaining( - 'Cannot perform action due to constraint(s) failure', - ), - ); - } - await expect(element(by.id(offTestID))).toHaveValue('0'); - await expect(element(by.id(offIndicatorID))).toHaveText('Off'); + try { + await element(by.id(onTestID)).tap(); + throw new Error('Does not match'); + } catch (err) { + jestExpect(err.message.message).toEqual( + jestExpect.stringContaining( + 'Cannot perform action due to constraint(s) failure', + ), + ); + } + await expect(element(by.id(onTestID))).toHaveValue('1'); + await expect(element(by.id(onIndicatorID))).toHaveText('On'); + + await expect(element(by.id(offTestID))).toHaveValue('0'); + await expect(element(by.id(offIndicatorID))).toHaveText('Off'); + try { + await element(by.id(offTestID)).tap(); + throw new Error('Does not match'); + } catch (err) { + jestExpect(err.message.message).toEqual( + jestExpect.stringContaining( + 'Cannot perform action due to constraint(s) failure', + ), + ); + } + await expect(element(by.id(offTestID))).toHaveValue('0'); + await expect(element(by.id(offIndicatorID))).toHaveText('Off'); + }); }); }); diff --git a/RNTester/e2e/__tests__/Touchable-test.js b/RNTester/e2e/__tests__/Touchable-test.js index 6ac25fdeca73..645fa80f1823 100644 --- a/RNTester/e2e/__tests__/Touchable-test.js +++ b/RNTester/e2e/__tests__/Touchable-test.js @@ -24,6 +24,9 @@ describe('Touchable', () => { }); it('Touchable Highlight should be tappable', async () => { + await element(by.id('explorer_example_search')).replaceText( + '', + ); const buttonID = 'touchable_highlight_image_button'; const button2ID = 'touchable_highlight_text_button'; const consoleID = 'touchable_highlight_console'; @@ -45,6 +48,9 @@ describe('Touchable', () => { }); it('Touchable Without Feedback should be tappable', async () => { + await element(by.id('explorer_example_search')).replaceText( + '', + ); const buttonID = 'touchable_without_feedback_button'; const consoleID = 'touchable_without_feedback_console'; @@ -60,6 +66,9 @@ describe('Touchable', () => { }); it('Text should be tappable', async () => { + await element(by.id('explorer_example_search')).replaceText( + ' with highlight', + ); const buttonID = 'tappable_text'; const consoleID = 'tappable_text_console'; diff --git a/RNTester/js/ActivityIndicatorExample.js b/RNTester/js/ActivityIndicatorExample.js index 937b368a443b..1da6d686d884 100644 --- a/RNTester/js/ActivityIndicatorExample.js +++ b/RNTester/js/ActivityIndicatorExample.js @@ -67,6 +67,22 @@ class ToggleAnimatingActivityIndicator extends Component< } } +const styles = StyleSheet.create({ + centering: { + alignItems: 'center', + justifyContent: 'center', + padding: 8, + }, + gray: { + backgroundColor: '#cccccc', + }, + horizontal: { + flexDirection: 'row', + justifyContent: 'space-around', + padding: 8, + }, +}); + exports.displayName = (undefined: ?string); exports.framework = 'React'; exports.title = ''; @@ -158,19 +174,3 @@ exports.examples = [ }, }, ]; - -const styles = StyleSheet.create({ - centering: { - alignItems: 'center', - justifyContent: 'center', - padding: 8, - }, - gray: { - backgroundColor: '#cccccc', - }, - horizontal: { - flexDirection: 'row', - justifyContent: 'space-around', - padding: 8, - }, -}); diff --git a/RNTester/js/AlertIOSExample.js b/RNTester/js/AlertIOSExample.js index 16868ce504a1..a33c06f5ee9d 100644 --- a/RNTester/js/AlertIOSExample.js +++ b/RNTester/js/AlertIOSExample.js @@ -16,58 +16,6 @@ const {StyleSheet, View, Text, TouchableHighlight, AlertIOS} = ReactNative; const {SimpleAlertExampleBlock} = require('./AlertExample'); -exports.framework = 'React'; -exports.title = 'AlertIOS'; -exports.description = 'iOS alerts and action sheets'; -exports.examples = [ - { - title: 'Alerts', - render() { - return ; - }, - }, - { - title: 'Prompt Options', - render(): React.Element { - return ; - }, - }, - { - title: 'Prompt Types', - render() { - return ( - - AlertIOS.prompt('Plain Text Entry')}> - - plain-text - - - - AlertIOS.prompt('Secure Text', null, null, 'secure-text') - }> - - secure-text - - - - AlertIOS.prompt('Login & Password', null, null, 'login-password') - }> - - login-password - - - - ); - }, - }, -]; - class PromptOptions extends React.Component<$FlowFixMeProps, any> { customButtons: Array; @@ -196,3 +144,55 @@ const styles = StyleSheet.create({ fontWeight: 'bold', }, }); + +exports.framework = 'React'; +exports.title = 'AlertIOS'; +exports.description = 'iOS alerts and action sheets'; +exports.examples = [ + { + title: 'Alerts', + render() { + return ; + }, + }, + { + title: 'Prompt Options', + render(): React.Element { + return ; + }, + }, + { + title: 'Prompt Types', + render() { + return ( + + AlertIOS.prompt('Plain Text Entry')}> + + plain-text + + + + AlertIOS.prompt('Secure Text', null, null, 'secure-text') + }> + + secure-text + + + + AlertIOS.prompt('Login & Password', null, null, 'login-password') + }> + + login-password + + + + ); + }, + }, +]; diff --git a/RNTester/js/AnimatedExample.js b/RNTester/js/AnimatedExample.js index 1802d03a2719..7e26c9f9fa57 100644 --- a/RNTester/js/AnimatedExample.js +++ b/RNTester/js/AnimatedExample.js @@ -15,6 +15,22 @@ const ReactNative = require('react-native'); const {Animated, Easing, StyleSheet, Text, View} = ReactNative; const RNTesterButton = require('./RNTesterButton'); +const styles = StyleSheet.create({ + content: { + backgroundColor: 'deepskyblue', + borderWidth: 1, + borderColor: 'dodgerblue', + padding: 20, + margin: 20, + borderRadius: 10, + alignItems: 'center', + }, + rotatingImage: { + width: 70, + height: 70, + }, +}); + exports.framework = 'React'; exports.title = 'Animated - Examples'; exports.description = @@ -287,19 +303,3 @@ exports.examples = [ render: () => Checkout the Gratuitous Animation App!, }, ]; - -const styles = StyleSheet.create({ - content: { - backgroundColor: 'deepskyblue', - borderWidth: 1, - borderColor: 'dodgerblue', - padding: 20, - margin: 20, - borderRadius: 10, - alignItems: 'center', - }, - rotatingImage: { - width: 70, - height: 70, - }, -}); diff --git a/RNTester/js/AnimatedGratuitousApp/AnExApp.js b/RNTester/js/AnimatedGratuitousApp/AnExApp.js index f9aa375a7d96..be1142bd4544 100644 --- a/RNTester/js/AnimatedGratuitousApp/AnExApp.js +++ b/RNTester/js/AnimatedGratuitousApp/AnExApp.js @@ -195,11 +195,6 @@ class Circle extends React.Component { } class AnExApp extends React.Component { - static title = 'Animated - Gratuitous App'; - static description = - 'Bunch of Animations - tap a circle to ' + - 'open a view with more animations, or longPress and drag to reorder circles.'; - _onMove: (position: Point) => void; constructor(props: any): void { super(props); @@ -365,4 +360,14 @@ const styles = StyleSheet.create({ }, }); -module.exports = AnExApp; +exports.title = 'Animated - Gratuitous App'; +exports.description = + 'Bunch of Animations - tap a circle to open a view with more animations, or longPress and drag to reorder circles.'; +exports.examples = [ + { + title: 'And example app', + render(): React.Element { + return ; + }, + }, +]; diff --git a/RNTester/js/ButtonExample.js b/RNTester/js/ButtonExample.js index ccabd4ae7862..cdea028cf226 100644 --- a/RNTester/js/ButtonExample.js +++ b/RNTester/js/ButtonExample.js @@ -18,6 +18,13 @@ function onButtonPress(buttonName) { Alert.alert(`${buttonName} has been pressed!`); } +const styles = StyleSheet.create({ + container: { + flexDirection: 'row', + justifyContent: 'space-between', + }, +}); + exports.displayName = 'ButtonExample'; exports.framework = 'React'; exports.title = '