diff --git a/tests/init-with-example/__snapshots__/init-with-example-with-log.test.js.snap b/tests/init-with-example/__snapshots__/init-with-example-with-log.test.js.snap index f871b5d6..8e93d8f8 100644 --- a/tests/init-with-example/__snapshots__/init-with-example-with-log.test.js.snap +++ b/tests/init-with-example/__snapshots__/init-with-example-with-log.test.js.snap @@ -10,142 +10,124 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "message": "What is the desired native module name?", - "name": "nativeModuleNameInput", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "message": "What is the desired native module name?", + "name": "nativeModuleNameInput", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "active": "yes", - "inactive": "no", - "initial": false, - "message": "Should it be a view?", - "name": "isView", - "onState": [Function], - "type": "toggle", - }, - ], - }, + "prompts": Array [ + Object { + "active": "yes", + "inactive": "no", + "initial": false, + "message": "Should it be a view?", + "name": "isView", + "onState": [Function], + "type": "toggle", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native-test-module", - "message": "What is the full module package name?", - "name": "modulePackageName", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native-test-module", + "message": "What is the full module package name?", + "name": "modulePackageName", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Initial package version is 1.0.0 - continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Initial package version is 1.0.0 - continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "", - "message": "What is the desired native object class name prefix (can be blank)?", - "name": "nativeObjectClassNamePrefixInput", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "", + "message": "What is the desired native object class name prefix (can be blank)?", + "name": "nativeObjectClassNamePrefixInput", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Native class name is NATIVETestModule. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Native class name is NATIVETestModule. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "choices": Array [ - Object { - "selected": true, - "title": "Android", - "value": "android", - }, - Object { - "selected": true, - "title": "iOS", - "value": "ios", - }, - Object { - "disabled": true, - "title": "Windows", - "value": "windows", - }, - ], - "message": "Which native platforms?", - "min": 1, - "name": "platforms", - "onState": [Function], - "type": "multiselect", - }, - ], - }, + "prompts": Array [ + Object { + "choices": Array [ + Object { + "selected": true, + "title": "Android", + "value": "android", + }, + Object { + "selected": true, + "title": "iOS", + "value": "ios", + }, + Object { + "disabled": true, + "title": "Windows", + "value": "windows", + }, + ], + "message": "Which native platforms?", + "min": 1, + "name": "platforms", + "onState": [Function], + "type": "multiselect", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "com.demo", - "message": "What is the desired Android package id?", - "name": "androidPackageId", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "com.demo", + "message": "What is the desired Android package id?", + "name": "androidPackageId", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": false, - "message": "Support Apple tvOS (requires react-native-tvos fork)?", - "name": "tvosEnabled", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": false, + "message": "Support Apple tvOS (requires react-native-tvos fork)?", + "name": "tvosEnabled", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ @@ -168,56 +150,48 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "Alice", - "message": "What is the author name?", - "name": "authorName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "Alice", + "message": "What is the author name?", + "name": "authorName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "alice@example.com", - "message": "What is the author email?", - "name": "authorEmail", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "alice@example.com", + "message": "What is the author email?", + "name": "authorEmail", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "ada", - "message": "What is the GitHub user account name?", - "name": "githubUserAccountName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "ada", + "message": "What is the GitHub user account name?", + "name": "githubUserAccountName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "MIT", - "message": "What license?", - "name": "license", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "MIT", + "message": "What license?", + "name": "license", + "onState": [Function], + "type": "text", + }, + ], }, Object { "log": Array [ @@ -238,56 +212,48 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Generate the example app (with workarounds in metro.config.js)?", - "name": "generateExampleApp", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Generate the example app (with workarounds in metro.config.js)?", + "name": "generateExampleApp", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "example", - "message": "Example app name?", - "name": "exampleAppName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "example", + "message": "Example app name?", + "name": "exampleAppName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native@latest", - "message": "What react-native version to use for the example app (should be at least react-native@0.60)?", - "name": "reactNativeVersion", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native@latest", + "message": "What react-native version to use for the example app (should be at least react-native@0.60)?", + "name": "reactNativeVersion", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Show the output of React Native CLI (recommended)?", - "name": "showReactNativeOutput", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Show the output of React Native CLI (recommended)?", + "name": "showReactNativeOutput", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "log": Array [ diff --git a/tests/init-with-example/init-with-example-with-log.test.js b/tests/init-with-example/init-with-example-with-log.test.js index b4abcf3e..0d07f00e 100644 --- a/tests/init-with-example/init-with-example-with-log.test.js +++ b/tests/init-with-example/init-with-example-with-log.test.js @@ -27,12 +27,11 @@ jest.mock('console', () => ({ } })) -jest.mock('prompts', () => args => { - expect(Array.isArray(args)).toBe(true) - mockCallSnapshot.push({ prompts: { args } }) - const optionsArray = [].concat(args) - expect(optionsArray.length).toBe(1) - return Promise.resolve(mockPromptResponses[optionsArray[0].name]) +jest.mock('prompts', () => prompts => { + expect(Array.isArray(prompts)).toBe(true) + expect(prompts.length).toBe(1) + mockCallSnapshot.push({ prompts }) + return Promise.resolve(mockPromptResponses[prompts[0].name]) }) jest.mock('execa', () => (cmd, args, opts) => { diff --git a/tests/no-example/__snapshots__/no-example-with-log.test.js.snap b/tests/no-example/__snapshots__/no-example-with-log.test.js.snap index b601fcd4..138418cc 100644 --- a/tests/no-example/__snapshots__/no-example-with-log.test.js.snap +++ b/tests/no-example/__snapshots__/no-example-with-log.test.js.snap @@ -10,142 +10,124 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "message": "What is the desired native module name?", - "name": "nativeModuleNameInput", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "message": "What is the desired native module name?", + "name": "nativeModuleNameInput", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "active": "yes", - "inactive": "no", - "initial": false, - "message": "Should it be a view?", - "name": "isView", - "onState": [Function], - "type": "toggle", - }, - ], - }, + "prompts": Array [ + Object { + "active": "yes", + "inactive": "no", + "initial": false, + "message": "Should it be a view?", + "name": "isView", + "onState": [Function], + "type": "toggle", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native-test-module", - "message": "What is the full module package name?", - "name": "modulePackageName", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native-test-module", + "message": "What is the full module package name?", + "name": "modulePackageName", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Initial package version is 1.0.0 - continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Initial package version is 1.0.0 - continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "", - "message": "What is the desired native object class name prefix (can be blank)?", - "name": "nativeObjectClassNamePrefixInput", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "", + "message": "What is the desired native object class name prefix (can be blank)?", + "name": "nativeObjectClassNamePrefixInput", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Native class name is NATIVETestModule. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Native class name is NATIVETestModule. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "choices": Array [ - Object { - "selected": true, - "title": "Android", - "value": "android", - }, - Object { - "selected": true, - "title": "iOS", - "value": "ios", - }, - Object { - "disabled": true, - "title": "Windows", - "value": "windows", - }, - ], - "message": "Which native platforms?", - "min": 1, - "name": "platforms", - "onState": [Function], - "type": "multiselect", - }, - ], - }, + "prompts": Array [ + Object { + "choices": Array [ + Object { + "selected": true, + "title": "Android", + "value": "android", + }, + Object { + "selected": true, + "title": "iOS", + "value": "ios", + }, + Object { + "disabled": true, + "title": "Windows", + "value": "windows", + }, + ], + "message": "Which native platforms?", + "min": 1, + "name": "platforms", + "onState": [Function], + "type": "multiselect", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "com.demo", - "message": "What is the desired Android package id?", - "name": "androidPackageId", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "com.demo", + "message": "What is the desired Android package id?", + "name": "androidPackageId", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": false, - "message": "Support Apple tvOS (requires react-native-tvos fork)?", - "name": "tvosEnabled", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": false, + "message": "Support Apple tvOS (requires react-native-tvos fork)?", + "name": "tvosEnabled", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ @@ -168,56 +150,48 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "Alice", - "message": "What is the author name?", - "name": "authorName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "Alice", + "message": "What is the author name?", + "name": "authorName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "alice@example.com", - "message": "What is the author email?", - "name": "authorEmail", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "alice@example.com", + "message": "What is the author email?", + "name": "authorEmail", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "ada", - "message": "What is the GitHub user account name?", - "name": "githubUserAccountName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "ada", + "message": "What is the GitHub user account name?", + "name": "githubUserAccountName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "MIT", - "message": "What license?", - "name": "license", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "MIT", + "message": "What license?", + "name": "license", + "onState": [Function], + "type": "text", + }, + ], }, Object { "log": Array [ @@ -238,17 +212,15 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Generate the example app (with workarounds in metro.config.js)?", - "name": "generateExampleApp", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Generate the example app (with workarounds in metro.config.js)?", + "name": "generateExampleApp", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "log": Array [ diff --git a/tests/no-example/no-example-with-log.test.js b/tests/no-example/no-example-with-log.test.js index f1df568a..115afd2c 100644 --- a/tests/no-example/no-example-with-log.test.js +++ b/tests/no-example/no-example-with-log.test.js @@ -24,12 +24,11 @@ jest.mock('console', () => ({ } })) -jest.mock('prompts', () => args => { - expect(Array.isArray(args)).toBe(true) - mockCallSnapshot.push({ prompts: { args } }) - const optionsArray = [].concat(args) - expect(optionsArray.length).toBe(1) - return Promise.resolve(mockPromptResponses[optionsArray[0].name]) +jest.mock('prompts', () => prompts => { + expect(Array.isArray(prompts)).toBe(true) + expect(prompts.length).toBe(1) + mockCallSnapshot.push({ prompts }) + return Promise.resolve(mockPromptResponses[prompts[0].name]) }) jest.mock('execa', () => (cmd, args, opts) => { diff --git a/tests/tvos/view-with-example/__snapshots__/tvos-view-with-example.test.js.snap b/tests/tvos/view-with-example/__snapshots__/tvos-view-with-example.test.js.snap index e2b140b3..dd6cbdbd 100644 --- a/tests/tvos/view-with-example/__snapshots__/tvos-view-with-example.test.js.snap +++ b/tests/tvos/view-with-example/__snapshots__/tvos-view-with-example.test.js.snap @@ -3,155 +3,135 @@ exports[`generate native React Native view for tvOS, with example 1`] = ` Array [ Object { - "prompts": Object { - "args": Array [ - Object { - "message": "What is the desired native module name?", - "name": "nativeModuleNameInput", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "message": "What is the desired native module name?", + "name": "nativeModuleNameInput", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "active": "yes", - "inactive": "no", - "initial": false, - "message": "Should it be a view?", - "name": "isView", - "onState": [Function], - "type": "toggle", - }, - ], - }, + "prompts": Array [ + Object { + "active": "yes", + "inactive": "no", + "initial": false, + "message": "Should it be a view?", + "name": "isView", + "onState": [Function], + "type": "toggle", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "View name is is TestViewForTvOs. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "View name is is TestViewForTvOs. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native-test-view-for-tv-os", - "message": "What is the full module package name?", - "name": "modulePackageName", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native-test-view-for-tv-os", + "message": "What is the full module package name?", + "name": "modulePackageName", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Initial package version is 1.0.0 - continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Initial package version is 1.0.0 - continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "", - "message": "What is the desired native object class name prefix (can be blank)?", - "name": "nativeObjectClassNamePrefixInput", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "", + "message": "What is the desired native object class name prefix (can be blank)?", + "name": "nativeObjectClassNamePrefixInput", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Native class name is NATIVETestViewForTvOs. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Native class name is NATIVETestViewForTvOs. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "choices": Array [ - Object { - "selected": true, - "title": "Android", - "value": "android", - }, - Object { - "selected": true, - "title": "iOS", - "value": "ios", - }, - Object { - "disabled": true, - "title": "Windows", - "value": "windows", - }, - ], - "message": "Which native platforms?", - "min": 1, - "name": "platforms", - "onState": [Function], - "type": "multiselect", - }, - ], - }, + "prompts": Array [ + Object { + "choices": Array [ + Object { + "selected": true, + "title": "Android", + "value": "android", + }, + Object { + "selected": true, + "title": "iOS", + "value": "ios", + }, + Object { + "disabled": true, + "title": "Windows", + "value": "windows", + }, + ], + "message": "Which native platforms?", + "min": 1, + "name": "platforms", + "onState": [Function], + "type": "multiselect", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "com.demo", - "message": "What is the desired Android package id?", - "name": "androidPackageId", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "com.demo", + "message": "What is the desired Android package id?", + "name": "androidPackageId", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": false, - "message": "Support Apple tvOS (requires react-native-tvos fork)?", - "name": "tvosEnabled", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": false, + "message": "Support Apple tvOS (requires react-native-tvos fork)?", + "name": "tvosEnabled", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ @@ -174,108 +154,92 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "Alice", - "message": "What is the author name?", - "name": "authorName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "Alice", + "message": "What is the author name?", + "name": "authorName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "alice@example.com", - "message": "What is the author email?", - "name": "authorEmail", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "alice@example.com", + "message": "What is the author email?", + "name": "authorEmail", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "ada", - "message": "What is the GitHub user account name?", - "name": "githubUserAccountName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "ada", + "message": "What is the GitHub user account name?", + "name": "githubUserAccountName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "MIT", - "message": "What license?", - "name": "license", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "MIT", + "message": "What license?", + "name": "license", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Generate the example app (with workarounds in metro.config.js)?", - "name": "generateExampleApp", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Generate the example app (with workarounds in metro.config.js)?", + "name": "generateExampleApp", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "example", - "message": "Example app name?", - "name": "exampleAppName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "example", + "message": "Example app name?", + "name": "exampleAppName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native@npm:react-native-tvos", - "message": "What react-native version to use for the example app (should be at least react-native@npm:react-native-tvos@0.60)?", - "name": "reactNativeVersion", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native@npm:react-native-tvos", + "message": "What react-native version to use for the example app (should be at least react-native@npm:react-native-tvos@0.60)?", + "name": "reactNativeVersion", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Show the output of React Native CLI (recommended)?", - "name": "showReactNativeOutput", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Show the output of React Native CLI (recommended)?", + "name": "showReactNativeOutput", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ diff --git a/tests/tvos/view-with-example/tvos-view-with-example.test.js b/tests/tvos/view-with-example/tvos-view-with-example.test.js index 45c74989..aa0430f4 100644 --- a/tests/tvos/view-with-example/tvos-view-with-example.test.js +++ b/tests/tvos/view-with-example/tvos-view-with-example.test.js @@ -27,12 +27,11 @@ jest.mock('console', () => ({ } })) -jest.mock('prompts', () => args => { - expect(Array.isArray(args)).toBe(true) - mockCallSnapshot.push({ prompts: { args } }) - const optionsArray = [].concat(args) - expect(optionsArray.length).toBe(1) - return Promise.resolve(mockPromptResponses[optionsArray[0].name]) +jest.mock('prompts', () => prompts => { + expect(Array.isArray(prompts)).toBe(true) + expect(prompts.length).toBe(1) + mockCallSnapshot.push({ prompts }) + return Promise.resolve(mockPromptResponses[prompts[0].name]) }) jest.mock('execa', () => (cmd, args, opts) => { diff --git a/tests/tvos/with-example/__snapshots__/tvos-with-example.test.js.snap b/tests/tvos/with-example/__snapshots__/tvos-with-example.test.js.snap index a5f00652..9e6b44d2 100644 --- a/tests/tvos/with-example/__snapshots__/tvos-with-example.test.js.snap +++ b/tests/tvos/with-example/__snapshots__/tvos-with-example.test.js.snap @@ -3,142 +3,124 @@ exports[`generate native React Native module for tvOS with example 1`] = ` Array [ Object { - "prompts": Object { - "args": Array [ - Object { - "message": "What is the desired native module name?", - "name": "nativeModuleNameInput", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "message": "What is the desired native module name?", + "name": "nativeModuleNameInput", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "active": "yes", - "inactive": "no", - "initial": false, - "message": "Should it be a view?", - "name": "isView", - "onState": [Function], - "type": "toggle", - }, - ], - }, + "prompts": Array [ + Object { + "active": "yes", + "inactive": "no", + "initial": false, + "message": "Should it be a view?", + "name": "isView", + "onState": [Function], + "type": "toggle", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native-test-module-for-tv-os", - "message": "What is the full module package name?", - "name": "modulePackageName", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native-test-module-for-tv-os", + "message": "What is the full module package name?", + "name": "modulePackageName", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Initial package version is 1.0.0 - continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Initial package version is 1.0.0 - continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "", - "message": "What is the desired native object class name prefix (can be blank)?", - "name": "nativeObjectClassNamePrefixInput", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "", + "message": "What is the desired native object class name prefix (can be blank)?", + "name": "nativeObjectClassNamePrefixInput", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Native class name is NATIVETestModuleForTvOs. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Native class name is NATIVETestModuleForTvOs. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "choices": Array [ - Object { - "selected": true, - "title": "Android", - "value": "android", - }, - Object { - "selected": true, - "title": "iOS", - "value": "ios", - }, - Object { - "disabled": true, - "title": "Windows", - "value": "windows", - }, - ], - "message": "Which native platforms?", - "min": 1, - "name": "platforms", - "onState": [Function], - "type": "multiselect", - }, - ], - }, + "prompts": Array [ + Object { + "choices": Array [ + Object { + "selected": true, + "title": "Android", + "value": "android", + }, + Object { + "selected": true, + "title": "iOS", + "value": "ios", + }, + Object { + "disabled": true, + "title": "Windows", + "value": "windows", + }, + ], + "message": "Which native platforms?", + "min": 1, + "name": "platforms", + "onState": [Function], + "type": "multiselect", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "com.demo", - "message": "What is the desired Android package id?", - "name": "androidPackageId", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "com.demo", + "message": "What is the desired Android package id?", + "name": "androidPackageId", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": false, - "message": "Support Apple tvOS (requires react-native-tvos fork)?", - "name": "tvosEnabled", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": false, + "message": "Support Apple tvOS (requires react-native-tvos fork)?", + "name": "tvosEnabled", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ @@ -161,108 +143,92 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "Alice", - "message": "What is the author name?", - "name": "authorName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "Alice", + "message": "What is the author name?", + "name": "authorName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "alice@example.com", - "message": "What is the author email?", - "name": "authorEmail", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "alice@example.com", + "message": "What is the author email?", + "name": "authorEmail", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "ada", - "message": "What is the GitHub user account name?", - "name": "githubUserAccountName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "ada", + "message": "What is the GitHub user account name?", + "name": "githubUserAccountName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "MIT", - "message": "What license?", - "name": "license", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "MIT", + "message": "What license?", + "name": "license", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Generate the example app (with workarounds in metro.config.js)?", - "name": "generateExampleApp", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Generate the example app (with workarounds in metro.config.js)?", + "name": "generateExampleApp", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "example", - "message": "Example app name?", - "name": "exampleAppName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "example", + "message": "Example app name?", + "name": "exampleAppName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native@npm:react-native-tvos", - "message": "What react-native version to use for the example app (should be at least react-native@npm:react-native-tvos@0.60)?", - "name": "reactNativeVersion", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native@npm:react-native-tvos", + "message": "What react-native version to use for the example app (should be at least react-native@npm:react-native-tvos@0.60)?", + "name": "reactNativeVersion", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Show the output of React Native CLI (recommended)?", - "name": "showReactNativeOutput", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Show the output of React Native CLI (recommended)?", + "name": "showReactNativeOutput", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ diff --git a/tests/tvos/with-example/tvos-with-example.test.js b/tests/tvos/with-example/tvos-with-example.test.js index 249f2427..65c01655 100644 --- a/tests/tvos/with-example/tvos-with-example.test.js +++ b/tests/tvos/with-example/tvos-with-example.test.js @@ -27,12 +27,11 @@ jest.mock('console', () => ({ } })) -jest.mock('prompts', () => args => { - expect(Array.isArray(args)).toBe(true) - mockCallSnapshot.push({ prompts: { args } }) - const optionsArray = [].concat(args) - expect(optionsArray.length).toBe(1) - return Promise.resolve(mockPromptResponses[optionsArray[0].name]) +jest.mock('prompts', () => prompts => { + expect(Array.isArray(prompts)).toBe(true) + expect(prompts.length).toBe(1) + mockCallSnapshot.push({ prompts }) + return Promise.resolve(mockPromptResponses[prompts[0].name]) }) jest.mock('execa', () => (cmd, args, opts) => { diff --git a/tests/view/no-example/__snapshots__/init-view-no-example-with-log.test.js.snap b/tests/view/no-example/__snapshots__/init-view-no-example-with-log.test.js.snap index 96fbc7af..019391bd 100644 --- a/tests/view/no-example/__snapshots__/init-view-no-example-with-log.test.js.snap +++ b/tests/view/no-example/__snapshots__/init-view-no-example-with-log.test.js.snap @@ -10,155 +10,135 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "message": "What is the desired native module name?", - "name": "nativeModuleNameInput", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "message": "What is the desired native module name?", + "name": "nativeModuleNameInput", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "active": "yes", - "inactive": "no", - "initial": false, - "message": "Should it be a view?", - "name": "isView", - "onState": [Function], - "type": "toggle", - }, - ], - }, + "prompts": Array [ + Object { + "active": "yes", + "inactive": "no", + "initial": false, + "message": "Should it be a view?", + "name": "isView", + "onState": [Function], + "type": "toggle", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "View name is is TestView. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "View name is is TestView. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native-test-view", - "message": "What is the full module package name?", - "name": "modulePackageName", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native-test-view", + "message": "What is the full module package name?", + "name": "modulePackageName", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Initial package version is 1.0.0 - continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Initial package version is 1.0.0 - continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "", - "message": "What is the desired native object class name prefix (can be blank)?", - "name": "nativeObjectClassNamePrefixInput", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "", + "message": "What is the desired native object class name prefix (can be blank)?", + "name": "nativeObjectClassNamePrefixInput", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Native class name is NATIVETestView. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Native class name is NATIVETestView. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "choices": Array [ - Object { - "selected": true, - "title": "Android", - "value": "android", - }, - Object { - "selected": true, - "title": "iOS", - "value": "ios", - }, - Object { - "disabled": true, - "title": "Windows", - "value": "windows", - }, - ], - "message": "Which native platforms?", - "min": 1, - "name": "platforms", - "onState": [Function], - "type": "multiselect", - }, - ], - }, + "prompts": Array [ + Object { + "choices": Array [ + Object { + "selected": true, + "title": "Android", + "value": "android", + }, + Object { + "selected": true, + "title": "iOS", + "value": "ios", + }, + Object { + "disabled": true, + "title": "Windows", + "value": "windows", + }, + ], + "message": "Which native platforms?", + "min": 1, + "name": "platforms", + "onState": [Function], + "type": "multiselect", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "com.demo", - "message": "What is the desired Android package id?", - "name": "androidPackageId", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "com.demo", + "message": "What is the desired Android package id?", + "name": "androidPackageId", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": false, - "message": "Support Apple tvOS (requires react-native-tvos fork)?", - "name": "tvosEnabled", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": false, + "message": "Support Apple tvOS (requires react-native-tvos fork)?", + "name": "tvosEnabled", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ @@ -181,56 +161,48 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "Alice", - "message": "What is the author name?", - "name": "authorName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "Alice", + "message": "What is the author name?", + "name": "authorName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "alice@example.com", - "message": "What is the author email?", - "name": "authorEmail", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "alice@example.com", + "message": "What is the author email?", + "name": "authorEmail", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "ada", - "message": "What is the GitHub user account name?", - "name": "githubUserAccountName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "ada", + "message": "What is the GitHub user account name?", + "name": "githubUserAccountName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "MIT", - "message": "What license?", - "name": "license", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "MIT", + "message": "What license?", + "name": "license", + "onState": [Function], + "type": "text", + }, + ], }, Object { "log": Array [ @@ -251,17 +223,15 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Generate the example app (with workarounds in metro.config.js)?", - "name": "generateExampleApp", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Generate the example app (with workarounds in metro.config.js)?", + "name": "generateExampleApp", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "log": Array [ diff --git a/tests/view/no-example/init-view-no-example-with-log.test.js b/tests/view/no-example/init-view-no-example-with-log.test.js index 29e69540..2db026f6 100644 --- a/tests/view/no-example/init-view-no-example-with-log.test.js +++ b/tests/view/no-example/init-view-no-example-with-log.test.js @@ -24,12 +24,11 @@ jest.mock('console', () => ({ } })) -jest.mock('prompts', () => args => { - expect(Array.isArray(args)).toBe(true) - mockCallSnapshot.push({ prompts: { args } }) - const optionsArray = [].concat(args) - expect(optionsArray.length).toBe(1) - return Promise.resolve(mockPromptResponses[optionsArray[0].name]) +jest.mock('prompts', () => prompts => { + expect(Array.isArray(prompts)).toBe(true) + expect(prompts.length).toBe(1) + mockCallSnapshot.push({ prompts }) + return Promise.resolve(mockPromptResponses[prompts[0].name]) }) jest.mock('execa', () => (cmd, args, opts) => { diff --git a/tests/view/with-example/__snapshots__/init-view-with-example-with-log.test.js.snap b/tests/view/with-example/__snapshots__/init-view-with-example-with-log.test.js.snap index 2005ea12..b1da4a65 100644 --- a/tests/view/with-example/__snapshots__/init-view-with-example-with-log.test.js.snap +++ b/tests/view/with-example/__snapshots__/init-view-with-example-with-log.test.js.snap @@ -10,155 +10,135 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "message": "What is the desired native module name?", - "name": "nativeModuleNameInput", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "message": "What is the desired native module name?", + "name": "nativeModuleNameInput", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "active": "yes", - "inactive": "no", - "initial": false, - "message": "Should it be a view?", - "name": "isView", - "onState": [Function], - "type": "toggle", - }, - ], - }, + "prompts": Array [ + Object { + "active": "yes", + "inactive": "no", + "initial": false, + "message": "Should it be a view?", + "name": "isView", + "onState": [Function], + "type": "toggle", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "View name is is TestView. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "View name is is TestView. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native-test-view", - "message": "What is the full module package name?", - "name": "modulePackageName", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native-test-view", + "message": "What is the full module package name?", + "name": "modulePackageName", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Initial package version is 1.0.0 - continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Initial package version is 1.0.0 - continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "", - "message": "What is the desired native object class name prefix (can be blank)?", - "name": "nativeObjectClassNamePrefixInput", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "", + "message": "What is the desired native object class name prefix (can be blank)?", + "name": "nativeObjectClassNamePrefixInput", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Native class name is NATIVETestView. Continue?", - "name": "confirmation", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Native class name is NATIVETestView. Continue?", + "name": "confirmation", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "choices": Array [ - Object { - "selected": true, - "title": "Android", - "value": "android", - }, - Object { - "selected": true, - "title": "iOS", - "value": "ios", - }, - Object { - "disabled": true, - "title": "Windows", - "value": "windows", - }, - ], - "message": "Which native platforms?", - "min": 1, - "name": "platforms", - "onState": [Function], - "type": "multiselect", - }, - ], - }, + "prompts": Array [ + Object { + "choices": Array [ + Object { + "selected": true, + "title": "Android", + "value": "android", + }, + Object { + "selected": true, + "title": "iOS", + "value": "ios", + }, + Object { + "disabled": true, + "title": "Windows", + "value": "windows", + }, + ], + "message": "Which native platforms?", + "min": 1, + "name": "platforms", + "onState": [Function], + "type": "multiselect", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "com.demo", - "message": "What is the desired Android package id?", - "name": "androidPackageId", - "onState": [Function], - "type": "text", - "validate": [Function], - }, - ], - }, + "prompts": Array [ + Object { + "initial": "com.demo", + "message": "What is the desired Android package id?", + "name": "androidPackageId", + "onState": [Function], + "type": "text", + "validate": [Function], + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": false, - "message": "Support Apple tvOS (requires react-native-tvos fork)?", - "name": "tvosEnabled", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": false, + "message": "Support Apple tvOS (requires react-native-tvos fork)?", + "name": "tvosEnabled", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "execa": Array [ @@ -181,56 +161,48 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "Alice", - "message": "What is the author name?", - "name": "authorName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "Alice", + "message": "What is the author name?", + "name": "authorName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "alice@example.com", - "message": "What is the author email?", - "name": "authorEmail", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "alice@example.com", + "message": "What is the author email?", + "name": "authorEmail", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "ada", - "message": "What is the GitHub user account name?", - "name": "githubUserAccountName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "ada", + "message": "What is the GitHub user account name?", + "name": "githubUserAccountName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "MIT", - "message": "What license?", - "name": "license", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "MIT", + "message": "What license?", + "name": "license", + "onState": [Function], + "type": "text", + }, + ], }, Object { "log": Array [ @@ -251,56 +223,48 @@ Array [ ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Generate the example app (with workarounds in metro.config.js)?", - "name": "generateExampleApp", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Generate the example app (with workarounds in metro.config.js)?", + "name": "generateExampleApp", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "example", - "message": "Example app name?", - "name": "exampleAppName", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "example", + "message": "Example app name?", + "name": "exampleAppName", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": "react-native@latest", - "message": "What react-native version to use for the example app (should be at least react-native@0.60)?", - "name": "reactNativeVersion", - "onState": [Function], - "type": "text", - }, - ], - }, + "prompts": Array [ + Object { + "initial": "react-native@latest", + "message": "What react-native version to use for the example app (should be at least react-native@0.60)?", + "name": "reactNativeVersion", + "onState": [Function], + "type": "text", + }, + ], }, Object { - "prompts": Object { - "args": Array [ - Object { - "initial": true, - "message": "Show the output of React Native CLI (recommended)?", - "name": "showReactNativeOutput", - "onState": [Function], - "type": "confirm", - }, - ], - }, + "prompts": Array [ + Object { + "initial": true, + "message": "Show the output of React Native CLI (recommended)?", + "name": "showReactNativeOutput", + "onState": [Function], + "type": "confirm", + }, + ], }, Object { "log": Array [ diff --git a/tests/view/with-example/init-view-with-example-with-log.test.js b/tests/view/with-example/init-view-with-example-with-log.test.js index 84115616..d385cac0 100644 --- a/tests/view/with-example/init-view-with-example-with-log.test.js +++ b/tests/view/with-example/init-view-with-example-with-log.test.js @@ -27,12 +27,11 @@ jest.mock('console', () => ({ } })) -jest.mock('prompts', () => args => { - expect(Array.isArray(args)).toBe(true) - mockCallSnapshot.push({ prompts: { args } }) - const optionsArray = [].concat(args) - expect(optionsArray.length).toBe(1) - return Promise.resolve(mockPromptResponses[optionsArray[0].name]) +jest.mock('prompts', () => prompts => { + expect(Array.isArray(prompts)).toBe(true) + expect(prompts.length).toBe(1) + mockCallSnapshot.push({ prompts }) + return Promise.resolve(mockPromptResponses[prompts[0].name]) }) jest.mock('execa', () => (cmd, args, opts) => {