@@ -18,8 +18,9 @@ function createTestInjector() {
18
18
testInjector . register ( "analyticsService" , {
19
19
trackEventActionInGoogleAnalytics : ( ) => ( { } )
20
20
} ) ;
21
- testInjector . register ( "commandsService" , { currentCommandData : { commandName : "test" , commandArguments : [ "" ] } } ) ;
21
+ testInjector . register ( "commandsService" , { currentCommandData : { commandName : "test" , commandArguments : [ "" ] } } ) ;
22
22
testInjector . register ( "doctorService" , { } ) ;
23
+ testInjector . register ( "hooksService" , stubs . HooksServiceStub ) ;
23
24
testInjector . register ( "errors" , {
24
25
fail : ( err : any ) => {
25
26
throw new Error ( err . formatStr || err . message || err ) ;
@@ -47,21 +48,21 @@ describe("platformEnvironmentRequirements ", () => {
47
48
describe ( "checkRequirements" , ( ) => {
48
49
let testInjector : IInjector = null ;
49
50
let platformEnvironmentRequirements : IPlatformEnvironmentRequirements = null ;
50
- let promptForChoiceData : { message : string , choices : string [ ] } [ ] = [ ] ;
51
+ let promptForChoiceData : { message : string , choices : string [ ] } [ ] = [ ] ;
51
52
let isExtensionInstallCalled = false ;
52
53
53
- function mockDoctorService ( data : { canExecuteLocalBuild : boolean , mockSetupScript ?: boolean } ) {
54
+ function mockDoctorService ( data : { canExecuteLocalBuild : boolean , mockSetupScript ?: boolean } ) {
54
55
const doctorService = testInjector . resolve ( "doctorService" ) ;
55
56
doctorService . canExecuteLocalBuild = ( ) => data . canExecuteLocalBuild ;
56
57
if ( data . mockSetupScript ) {
57
58
doctorService . runSetupScript = ( ) => Promise . resolve ( ) ;
58
59
}
59
60
}
60
61
61
- function mockPrompter ( data : { firstCallOptionName : string , secondCallOptionName ?: string } ) {
62
+ function mockPrompter ( data : { firstCallOptionName : string , secondCallOptionName ?: string } ) {
62
63
const prompter = testInjector . resolve ( "prompter" ) ;
63
64
prompter . promptForChoice = ( message : string , choices : string [ ] ) => {
64
- promptForChoiceData . push ( { message : message , choices : choices } ) ;
65
+ promptForChoiceData . push ( { message : message , choices : choices } ) ;
65
66
66
67
if ( promptForChoiceData . length === 1 ) {
67
68
return Promise . resolve ( data . firstCallOptionName ) ;
@@ -73,7 +74,7 @@ describe("platformEnvironmentRequirements ", () => {
73
74
} ;
74
75
}
75
76
76
- function mockNativeScriptCloudExtensionService ( data : { isInstalled : boolean } ) {
77
+ function mockNativeScriptCloudExtensionService ( data : { isInstalled : boolean } ) {
77
78
const nativeScriptCloudExtensionService = testInjector . resolve ( "nativeScriptCloudExtensionService" ) ;
78
79
nativeScriptCloudExtensionService . isInstalled = ( ) => data . isInstalled ;
79
80
nativeScriptCloudExtensionService . install = ( ) => { isExtensionInstallCalled = true ; } ;
@@ -124,7 +125,7 @@ describe("platformEnvironmentRequirements ", () => {
124
125
mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME } ) ;
125
126
mockNativeScriptCloudExtensionService ( { isInstalled : true } ) ;
126
127
127
- await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideSyncToPreviewAppOption : true } } ) ) ;
128
+ await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideSyncToPreviewAppOption : true } } ) ) ;
128
129
assert . isTrue ( promptForChoiceData . length === 1 ) ;
129
130
assert . isTrue ( isExtensionInstallCalled ) ;
130
131
assert . deepEqual ( "To continue, choose one of the following options: " , promptForChoiceData [ 0 ] . message ) ;
@@ -135,13 +136,13 @@ describe("platformEnvironmentRequirements ", () => {
135
136
mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME } ) ;
136
137
mockNativeScriptCloudExtensionService ( { isInstalled : true } ) ;
137
138
138
- await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideCloudBuildOption : true } } ) ) ;
139
+ await assert . isRejected ( platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform, notConfiguredEnvOptions : { hideCloudBuildOption : true } } ) ) ;
139
140
assert . isTrue ( promptForChoiceData . length === 1 ) ;
140
141
assert . isTrue ( isExtensionInstallCalled ) ;
141
142
assert . deepEqual ( "To continue, choose one of the following options: " , promptForChoiceData [ 0 ] . message ) ;
142
143
assert . deepEqual ( [ 'Sync to Playground' , 'Configure for Local Builds' , 'Skip Step and Configure Manually' ] , promptForChoiceData [ 0 ] . choices ) ;
143
144
} ) ;
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 ( ) => {
145
146
( < any > process . env ) . NS_SKIP_ENV_CHECK = true ;
146
147
147
148
const output = await platformEnvironmentRequirements . checkEnvironmentRequirements ( { platform } ) ;
@@ -153,7 +154,7 @@ describe("platformEnvironmentRequirements ", () => {
153
154
154
155
describe ( "when local setup option is selected" , ( ) => {
155
156
beforeEach ( ( ) => {
156
- mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME } ) ;
157
+ mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME } ) ;
157
158
} ) ;
158
159
159
160
it ( "should return true when env is configured after executing setup script" , async ( ) => {
@@ -169,7 +170,7 @@ describe("platformEnvironmentRequirements ", () => {
169
170
170
171
describe ( "and env is not configured after executing setup script" , ( ) => {
171
172
it ( "should setup manually when cloud extension is installed" , async ( ) => {
172
- mockDoctorService ( { canExecuteLocalBuild : false , mockSetupScript : true } ) ;
173
+ mockDoctorService ( { canExecuteLocalBuild : false , mockSetupScript : true } ) ;
173
174
mockPrompter ( { firstCallOptionName : PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME , secondCallOptionName : PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME } ) ;
174
175
mockNativeScriptCloudExtensionService ( { isInstalled : true } ) ;
175
176
0 commit comments