4
4
import yok = require( '../lib/common/yok' ) ;
5
5
import stubs = require( './stubs' ) ;
6
6
import * as constants from "./../lib/constants" ;
7
- import * as ChildProcessLib from "../lib/common/child-process" ;
7
+ import { ChildProcess } from "../lib/common/child-process" ;
8
8
import * as ProjectServiceLib from "../lib/services/project-service" ;
9
9
import * as ProjectDataServiceLib from "../lib/services/project-data-service" ;
10
10
import * as ProjectDataLib from "../lib/project-data" ;
@@ -20,6 +20,7 @@ import * as helpers from "../lib/common/helpers";
20
20
import { assert } from "chai" ;
21
21
import * as optionsLib from "../lib/options" ;
22
22
import * as hostInfoLib from "../lib/common/host-info" ;
23
+ import iOSProjectServiceLib = require( "../lib/services/ios-project-service" ) ;
23
24
24
25
let mockProjectNameValidator = {
25
26
validate : ( ) => { return true ; }
@@ -102,7 +103,7 @@ class ProjectIntegrationTest {
102
103
103
104
private createTestInjector ( ) : void {
104
105
this . testInjector = new yok . Yok ( ) ;
105
- this . testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
106
+ this . testInjector . register ( "childProcess" , ChildProcess ) ;
106
107
this . testInjector . register ( "errors" , stubs . ErrorsStub ) ;
107
108
this . testInjector . register ( 'logger' , stubs . LoggerStub ) ;
108
109
this . testInjector . register ( "projectService" , ProjectServiceLib . ProjectService ) ;
@@ -157,9 +158,10 @@ describe("Project Service Tests", () => {
157
158
return ;
158
159
}
159
160
160
- let testInjector = createTestInjector ( ) ;
161
+ let testInjector = createInjectorForPodsTest ( ) ;
162
+
163
+ let iOSProjectService : IPlatformProjectService = testInjector . resolve ( "iOSProjectService" ) ;
161
164
let fs : IFileSystem = testInjector . resolve ( "fs" ) ;
162
- let config = testInjector . resolve ( "config" ) ;
163
165
let childProcess = testInjector . resolve ( "childProcess" ) ;
164
166
let projectIntegrationTest = new ProjectIntegrationTest ( ) ;
165
167
let workingFolderPath = temp . mkdirSync ( "ios_project" ) ;
@@ -172,8 +174,20 @@ describe("Project Service Tests", () => {
172
174
let podfileContent = `post_install do |installer_representation| ${ postInstallCommmand } end` ;
173
175
fs . writeFile ( path . join ( workingFolderPath , "Podfile" ) , podfileContent ) . wait ( ) ;
174
176
175
- let podTool = config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ;
176
- childProcess . spawnFromEvent ( podTool , [ "install" ] , "close" , { cwd : workingFolderPath , stdio : 'inherit' } ) . wait ( ) ;
177
+ let platformData = iOSProjectService . platformData ;
178
+ Object . defineProperty ( iOSProjectService , "platformData" , {
179
+ get : ( ) => {
180
+ return { projectRoot : workingFolderPath } ;
181
+ }
182
+ } ) ;
183
+
184
+ try {
185
+ iOSProjectService . afterPrepareAllPlugins ( ) . wait ( ) ;
186
+ } catch ( e ) {
187
+ assert . isNotNull ( e ) ;
188
+ } finally {
189
+ Object . defineProperty ( iOSProjectService , "platformData" , platformData ) ;
190
+ }
177
191
178
192
assert . isTrue ( fs . exists ( "/tmp/Podfile" ) . wait ( ) ) ;
179
193
assert . isTrue ( fs . exists ( path . join ( workingFolderPath , "copyTestFile.txt" ) ) . wait ( ) ) ;
@@ -189,6 +203,7 @@ function createTestInjector() {
189
203
testInjector . register ( "projectService" , ProjectServiceLib . ProjectService ) ;
190
204
testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
191
205
testInjector . register ( "projectTemplatesService" , stubs . ProjectTemplatesService ) ;
206
+ testInjector . register ( "projectNameValidator" , mockProjectNameValidator ) ;
192
207
193
208
testInjector . register ( "fs" , fsLib . FileSystem ) ;
194
209
testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
@@ -197,12 +212,9 @@ function createTestInjector() {
197
212
198
213
testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
199
214
testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
200
- testInjector . register ( "config" , {
201
- "USE_POD_SANDBOX" : true
202
- } ) ;
203
215
testInjector . register ( "lockfile" , stubs . LockFile ) ;
204
216
205
- testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
217
+ testInjector . register ( "childProcess" , ChildProcess ) ;
206
218
207
219
testInjector . register ( 'projectData' , ProjectDataLib . ProjectData ) ;
208
220
testInjector . register ( "options" , optionsLib . Options ) ;
@@ -211,6 +223,33 @@ function createTestInjector() {
211
223
return testInjector ;
212
224
}
213
225
226
+ function createInjectorForPodsTest ( ) {
227
+ let testInjector = new yok . Yok ( ) ;
228
+
229
+ testInjector . register ( "errors" , stubs . ErrorsStub ) ;
230
+ testInjector . register ( 'logger' , stubs . LoggerStub ) ;
231
+ testInjector . register ( "projectHelper" , { } ) ;
232
+ testInjector . register ( "projectData" , {
233
+ projectName : "__PROJECT_NAME__" ,
234
+ platformsDir : ""
235
+ } ) ;
236
+ testInjector . register ( "projectDataService" , { } ) ;
237
+ testInjector . register ( "iOSEmulatorServices" , { } ) ;
238
+ testInjector . register ( "config" , {
239
+ "USE_POD_SANDBOX" : true
240
+ } ) ;
241
+ testInjector . register ( "prompter" , { } ) ;
242
+ testInjector . register ( "fs" , fsLib . FileSystem ) ;
243
+ testInjector . register ( "staticConfig" , StaticConfigLib . StaticConfig ) ;
244
+ testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
245
+ testInjector . register ( "iOSProjectService" , iOSProjectServiceLib . IOSProjectService ) ;
246
+ testInjector . register ( "childProcess" , ChildProcess ) ;
247
+ testInjector . register ( "options" , optionsLib . Options ) ;
248
+ testInjector . register ( "hostInfo" , hostInfoLib . HostInfo ) ;
249
+
250
+ return testInjector ;
251
+ }
252
+
214
253
describe ( "project upgrade procedure tests" , ( ) => {
215
254
it ( "should throw error when no nativescript project folder specified" , ( ) => {
216
255
let testInjector = createTestInjector ( ) ;
0 commit comments