@@ -18,8 +18,9 @@ function createTestInjector() {
1818 testInjector . register ( "analyticsService" , {
1919 trackEventActionInGoogleAnalytics : ( ) => ( { } )
2020 } ) ;
21- testInjector . register ( "commandsService" , { currentCommandData : { commandName : "test" , commandArguments : [ "" ] } } ) ;
21+ testInjector . register ( "commandsService" , { currentCommandData : { commandName : "test" , commandArguments : [ "" ] } } ) ;
2222 testInjector . register ( "doctorService" , { } ) ;
23+ testInjector . register ( "hooksService" , stubs . HooksServiceStub ) ;
2324 testInjector . register ( "errors" , {
2425 fail : ( err : any ) => {
2526 throw new Error ( err . formatStr || err . message || err ) ;
@@ -47,21 +48,21 @@ describe("platformEnvironmentRequirements ", () => {
4748 describe ( "checkRequirements" , ( ) => {
4849 let testInjector : IInjector = null ;
4950 let platformEnvironmentRequirements : IPlatformEnvironmentRequirements = null ;
50- let promptForChoiceData : { message : string , choices : string [ ] } [ ] = [ ] ;
51+ let promptForChoiceData : { message : string , choices : string [ ] } [ ] = [ ] ;
5152 let isExtensionInstallCalled = false ;
5253
53- function mockDoctorService ( data : { canExecuteLocalBuild : boolean , mockSetupScript ?: boolean } ) {
54+ function mockDoctorService ( data : { canExecuteLocalBuild : boolean , mockSetupScript ?: boolean } ) {
5455 const doctorService = testInjector . resolve ( "doctorService" ) ;
5556 doctorService . canExecuteLocalBuild = ( ) => data . canExecuteLocalBuild ;
5657 if ( data . mockSetupScript ) {
5758 doctorService . runSetupScript = ( ) => Promise . resolve ( ) ;
5859 }
5960 }
6061
61- function mockPrompter ( data : { firstCallOptionName : string , secondCallOptionName ?: string } ) {
62+ function mockPrompter ( data : { firstCallOptionName : string , secondCallOptionName ?: string } ) {
6263 const prompter = testInjector . resolve ( "prompter" ) ;
6364 prompter . promptForChoice = ( message : string , choices : string [ ] ) => {
64- promptForChoiceData . push ( { message : message , choices : choices } ) ;
65+ promptForChoiceData . push ( { message : message , choices : choices } ) ;
6566
6667 if ( promptForChoiceData . length === 1 ) {
6768 return Promise . resolve ( data . firstCallOptionName ) ;
@@ -73,7 +74,7 @@ describe("platformEnvironmentRequirements ", () => {
7374 } ;
7475 }
7576
76- function mockNativeScriptCloudExtensionService ( data : { isInstalled : boolean } ) {
77+ function mockNativeScriptCloudExtensionService ( data : { isInstalled : boolean } ) {
7778 const nativeScriptCloudExtensionService = testInjector . resolve ( "nativeScriptCloudExtensionService" ) ;
7879 nativeScriptCloudExtensionService . isInstalled = ( ) => data . isInstalled ;
7980 nativeScriptCloudExtensionService . install = ( ) => { isExtensionInstallCalled = true ; } ;
@@ -124,7 +125,7 @@ describe("platformEnvironmentRequirements ", () => {
124125 mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME } ) ;
125126 mockNativeScriptCloudExtensionService ( { isInstalled : true } ) ;
126127
127- await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideSyncToPreviewAppOption : true } } ) ) ;
128+ await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideSyncToPreviewAppOption : true } } ) ) ;
128129 assert . isTrue ( promptForChoiceData . length === 1 ) ;
129130 assert . isTrue ( isExtensionInstallCalled ) ;
130131 assert . deepEqual ( "To continue, choose one of the following options: " , promptForChoiceData [ 0 ] . message ) ;
@@ -135,13 +136,13 @@ describe("platformEnvironmentRequirements ", () => {
135136 mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME } ) ;
136137 mockNativeScriptCloudExtensionService ( { isInstalled : true } ) ;
137138
138- await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideCloudBuildOption : true } } ) ) ;
139+ await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideCloudBuildOption : true } } ) ) ;
139140 assert . isTrue ( promptForChoiceData . length === 1 ) ;
140141 assert . isTrue ( isExtensionInstallCalled ) ;
141142 assert . deepEqual ( "To continue, choose one of the following options: " , promptForChoiceData [ 0 ] . message ) ;
142143 assert . deepEqual ( [ 'Sync to Playground' , 'Configure for Local Builds' , 'Skip Step and Configure Manually' ] , promptForChoiceData [ 0 ] . choices ) ;
143144 } ) ;
144- it ( "should skip env check when NS_SKIP_ENV_CHECK environment variable is passed" , async ( ) => {
145+ it ( "should skip env check when NS_SKIP_ENV_CHECK environment variable is passed" , async ( ) => {
145146 ( < any > process . env ) . NS_SKIP_ENV_CHECK = true ;
146147
147148 const output = await platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform } ) ;
@@ -153,7 +154,7 @@ describe("platformEnvironmentRequirements ", () => {
153154
154155 describe ( "when local setup option is selected" , ( ) => {
155156 beforeEach ( ( ) => {
156- mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME } ) ;
157+ mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME } ) ;
157158 } ) ;
158159
159160 it ( "should return true when env is configured after executing setup script" , async ( ) => {
@@ -169,7 +170,7 @@ describe("platformEnvironmentRequirements ", () => {
169170
170171 describe ( "and env is not configured after executing setup script" , ( ) => {
171172 it ( "should setup manually when cloud extension is installed" , async ( ) => {
172- mockDoctorService ( { canExecuteLocalBuild : false , mockSetupScript : true } ) ;
173+ mockDoctorService ( { canExecuteLocalBuild : false , mockSetupScript : true } ) ;
173174 mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME , secondCallOptionName : PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME } ) ;
174175 mockNativeScriptCloudExtensionService ( { isInstalled : true } ) ;
175176
0 commit comments