@@ -9,18 +9,19 @@ 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" ;
11
11
import * as ProjectHelperLib from "../lib/common/project-helper" ;
12
- import * as StaticConfigLib from "../lib/config" ;
12
+ import { StaticConfig } from "../lib/config" ;
13
13
import * as NpmLib from "../lib/node-package-manager" ;
14
- import * as NpmInstallationManagerLib from "../lib/npm-installation-manager" ;
14
+ import { NpmInstallationManager } from "../lib/npm-installation-manager" ;
15
15
import * as HttpClientLib from "../lib/common/http-client" ;
16
- import * as fsLib from "../lib/common/file-system" ;
16
+ import { FileSystem } from "../lib/common/file-system" ;
17
17
import * as path from "path" ;
18
18
import temp = require( "temp" ) ;
19
19
import * as helpers from "../lib/common/helpers" ;
20
20
import { assert } from "chai" ;
21
- import * as optionsLib from "../lib/options" ;
22
- import * as hostInfoLib from "../lib/common/host-info" ;
23
- import iOSProjectServiceLib = require( "../lib/services/ios-project-service" ) ;
21
+ import { Options } from "../lib/options" ;
22
+ import { HostInfo } from "../lib/common/host-info" ;
23
+ import { IOSProjectService } from "../lib/services/ios-project-service" ;
24
+ import * as shell from "shelljs" ;
24
25
25
26
let mockProjectNameValidator = {
26
27
validate : ( ) => { return true ; }
@@ -111,17 +112,17 @@ class ProjectIntegrationTest {
111
112
this . testInjector . register ( "projectTemplatesService" , stubs . ProjectTemplatesService ) ;
112
113
this . testInjector . register ( "projectNameValidator" , mockProjectNameValidator ) ;
113
114
114
- this . testInjector . register ( "fs" , fsLib . FileSystem ) ;
115
+ this . testInjector . register ( "fs" , FileSystem ) ;
115
116
this . testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
116
- this . testInjector . register ( "staticConfig" , StaticConfigLib . StaticConfig ) ;
117
+ this . testInjector . register ( "staticConfig" , StaticConfig ) ;
117
118
118
- this . testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
119
+ this . testInjector . register ( "npmInstallationManager" , NpmInstallationManager ) ;
119
120
this . testInjector . register ( "npm" , NpmLib . NodePackageManager ) ;
120
121
this . testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
121
122
this . testInjector . register ( "lockfile" , stubs . LockFile ) ;
122
123
123
- this . testInjector . register ( "options" , optionsLib . Options ) ;
124
- this . testInjector . register ( "hostInfo" , hostInfoLib . HostInfo ) ;
124
+ this . testInjector . register ( "options" , Options ) ;
125
+ this . testInjector . register ( "hostInfo" , HostInfo ) ;
125
126
}
126
127
}
127
128
@@ -158,19 +159,19 @@ describe("Project Service Tests", () => {
158
159
return ;
159
160
}
160
161
162
+ let testDirectoryPath = "/tmp/Podfile" ;
161
163
let testInjector = createInjectorForPodsTest ( ) ;
162
164
163
165
let iOSProjectService : IPlatformProjectService = testInjector . resolve ( "iOSProjectService" ) ;
164
166
let fs : IFileSystem = testInjector . resolve ( "fs" ) ;
165
- let childProcess = testInjector . resolve ( "childProcess" ) ;
166
167
let projectIntegrationTest = new ProjectIntegrationTest ( ) ;
167
168
let workingFolderPath = temp . mkdirSync ( "ios_project" ) ;
168
169
169
170
let iosTemplatePath = path . join ( projectIntegrationTest . getNpmPackagePath ( "tns-ios" ) . wait ( ) , "framework/" ) ;
170
- childProcess . exec ( `cp -R ${ iosTemplatePath } ${ workingFolderPath } ` , { cwd : workingFolderPath } ) . wait ( ) ;
171
- fs . writeFile ( "/tmp/Podfile/ testFile.txt" , "Test content." ) . wait ( ) ;
171
+ shell . cp ( "-R" , iosTemplatePath , workingFolderPath ) ;
172
+ fs . writeFile ( ` ${ testDirectoryPath } / testFile.txt` , "Test content." ) . wait ( ) ;
172
173
173
- let postInstallCommmand = `\`cat /tmp/Podfile/ testFile.txt > ${ workingFolderPath } /copyTestFile.txt && rm -rf /tmp/Podfile \`` ;
174
+ let postInstallCommmand = `\`cat ${ testDirectoryPath } / testFile.txt > ${ workingFolderPath } /copyTestFile.txt && rm -rf ${ testDirectoryPath } \`` ;
174
175
let podfileContent = `post_install do |installer_representation| ${ postInstallCommmand } end` ;
175
176
fs . writeFile ( path . join ( workingFolderPath , "Podfile" ) , podfileContent ) . wait ( ) ;
176
177
@@ -179,18 +180,17 @@ describe("Project Service Tests", () => {
179
180
get : ( ) => {
180
181
return { projectRoot : workingFolderPath } ;
181
182
}
182
- } ) ;
183
+ } ) ;
183
184
184
185
try {
185
186
iOSProjectService . afterPrepareAllPlugins ( ) . wait ( ) ;
186
- } catch ( e ) {
187
- assert . isNotNull ( e ) ;
188
187
} finally {
189
- Object . defineProperty ( iOSProjectService , "platformData" , platformData ) ;
188
+ Object . defineProperty ( iOSProjectService , "platformData" , platformData ) ;
190
189
}
191
190
192
- assert . isTrue ( fs . exists ( "/tmp/Podfile" ) . wait ( ) ) ;
191
+ assert . isTrue ( fs . exists ( testDirectoryPath ) . wait ( ) ) ;
193
192
assert . isTrue ( fs . exists ( path . join ( workingFolderPath , "copyTestFile.txt" ) ) . wait ( ) ) ;
193
+ fs . deleteDirectory ( testDirectoryPath ) . wait ( ) ; // Clean up 'tmp' after test ends.
194
194
} ) ;
195
195
} ) ;
196
196
} ) ;
@@ -205,20 +205,20 @@ function createTestInjector() {
205
205
testInjector . register ( "projectTemplatesService" , stubs . ProjectTemplatesService ) ;
206
206
testInjector . register ( "projectNameValidator" , mockProjectNameValidator ) ;
207
207
208
- testInjector . register ( "fs" , fsLib . FileSystem ) ;
208
+ testInjector . register ( "fs" , FileSystem ) ;
209
209
testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
210
210
211
- testInjector . register ( "staticConfig" , StaticConfigLib . StaticConfig ) ;
211
+ testInjector . register ( "staticConfig" , StaticConfig ) ;
212
212
213
- testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
213
+ testInjector . register ( "npmInstallationManager" , NpmInstallationManager ) ;
214
214
testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
215
215
testInjector . register ( "lockfile" , stubs . LockFile ) ;
216
216
217
217
testInjector . register ( "childProcess" , ChildProcess ) ;
218
218
219
219
testInjector . register ( 'projectData' , ProjectDataLib . ProjectData ) ;
220
- testInjector . register ( "options" , optionsLib . Options ) ;
221
- testInjector . register ( "hostInfo" , hostInfoLib . HostInfo ) ;
220
+ testInjector . register ( "options" , Options ) ;
221
+ testInjector . register ( "hostInfo" , HostInfo ) ;
222
222
223
223
return testInjector ;
224
224
}
@@ -239,13 +239,17 @@ function createInjectorForPodsTest() {
239
239
"USE_POD_SANDBOX" : true
240
240
} ) ;
241
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 ) ;
242
+ testInjector . register ( "fs" , FileSystem ) ;
243
+ testInjector . register ( "staticConfig" , StaticConfig ) ;
244
+ testInjector . register ( "npmInstallationManager" , NpmInstallationManager ) ;
245
+ testInjector . register ( "iOSProjectService" , IOSProjectService ) ;
246
+ testInjector . register ( "projectService" , ProjectServiceLib . ProjectService ) ;
247
+ testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
248
+ testInjector . register ( "projectTemplatesService" , stubs . ProjectTemplatesService ) ;
249
+ testInjector . register ( "projectNameValidator" , mockProjectNameValidator ) ;
250
+ testInjector . register ( "options" , Options ) ;
251
+ testInjector . register ( "hostInfo" , HostInfo ) ;
246
252
testInjector . register ( "childProcess" , ChildProcess ) ;
247
- testInjector . register ( "options" , optionsLib . Options ) ;
248
- testInjector . register ( "hostInfo" , hostInfoLib . HostInfo ) ;
249
253
250
254
return testInjector ;
251
255
}
0 commit comments