@@ -39,21 +39,20 @@ class ProjectIntegrationTest {
39
39
return projectService . createProject ( projectName ) ;
40
40
}
41
41
42
- public getDefaultTemplatePath ( ) : IFuture < string > {
42
+ public getDefaultTemplatePath ( templateName : string ) : IFuture < string > {
43
43
return ( ( ) => {
44
44
let npmInstallationManager = this . testInjector . resolve ( "npmInstallationManager" ) ;
45
45
let fs = this . testInjector . resolve ( "fs" ) ;
46
46
47
- let defaultTemplatePackageName = "tns-template-hello-world" ;
48
47
let cacheRoot = npmInstallationManager . getCacheRootPath ( ) ;
49
- let defaultTemplatePath = path . join ( cacheRoot , defaultTemplatePackageName ) ;
50
- let latestVersion = npmInstallationManager . getLatestVersion ( defaultTemplatePackageName ) . wait ( ) ;
48
+ let defaultTemplatePath = path . join ( cacheRoot , templateName ) ;
49
+ let latestVersion = npmInstallationManager . getLatestVersion ( templateName ) . wait ( ) ;
51
50
52
51
if ( ! fs . exists ( path . join ( defaultTemplatePath , latestVersion ) ) . wait ( ) ) {
53
- npmInstallationManager . addToCache ( defaultTemplatePackageName , latestVersion ) . wait ( ) ;
52
+ npmInstallationManager . addToCache ( templateName , latestVersion ) . wait ( ) ;
54
53
}
55
54
if ( ! fs . exists ( path . join ( defaultTemplatePath , latestVersion , "package" , "app" ) ) . wait ( ) ) {
56
- npmInstallationManager . cacheUnpack ( defaultTemplatePackageName , latestVersion ) . wait ( ) ;
55
+ npmInstallationManager . cacheUnpack ( templateName , latestVersion ) . wait ( ) ;
57
56
}
58
57
59
58
return path . join ( defaultTemplatePath , latestVersion , "package" ) ;
@@ -118,7 +117,6 @@ class ProjectIntegrationTest {
118
117
this . testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
119
118
this . testInjector . register ( "npm" , NpmLib . NodePackageManager ) ;
120
119
this . testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
121
- this . testInjector . register ( "config" , { } ) ;
122
120
this . testInjector . register ( "lockfile" , stubs . LockFile ) ;
123
121
124
122
this . testInjector . register ( "options" , optionsLib . Options ) ;
@@ -135,7 +133,7 @@ describe("Project Service Tests", () => {
135
133
let options = projectIntegrationTest . testInjector . resolve ( "options" ) ;
136
134
137
135
options . path = tempFolder ;
138
- options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( ) . wait ( ) ;
136
+ options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( "tns-template-hello-world" ) . wait ( ) ;
139
137
140
138
projectIntegrationTest . createProject ( projectName ) . wait ( ) ;
141
139
projectIntegrationTest . assertProject ( tempFolder , projectName , "org.nativescript.myapp" ) . wait ( ) ;
@@ -147,12 +145,34 @@ describe("Project Service Tests", () => {
147
145
let options = projectIntegrationTest . testInjector . resolve ( "options" ) ;
148
146
149
147
options . path = tempFolder ;
150
- options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( ) . wait ( ) ;
148
+ options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( "tns-template-hello-world" ) . wait ( ) ;
151
149
options . appid = "my.special.id" ;
152
150
153
151
projectIntegrationTest . createProject ( projectName ) . wait ( ) ;
154
152
projectIntegrationTest . assertProject ( tempFolder , projectName , options . appid ) . wait ( ) ;
155
153
} ) ;
154
+ it ( "creates valid project and tests pod sandbox" , ( ) => {
155
+ let testInjector = createTestInjector ( ) ;
156
+ let fs : IFileSystem = testInjector . resolve ( "fs" ) ;
157
+ let config = testInjector . resolve ( "config" ) ;
158
+ let childProcess = testInjector . resolve ( "childProcess" ) ;
159
+ let projectIntegrationTest = new ProjectIntegrationTest ( ) ;
160
+ let workingFolderPath = temp . mkdirSync ( "ios_project" ) ;
161
+
162
+ let iosTemplatePath = path . join ( projectIntegrationTest . getDefaultTemplatePath ( "tns-ios" ) . wait ( ) , "framework/" ) ;
163
+ childProcess . exec ( `cp -R ${ iosTemplatePath } ${ workingFolderPath } ` , { cwd : workingFolderPath } ) . wait ( ) ;
164
+ fs . writeFile ( "/tmp/Podfile/testFile.txt" , "Test content." ) . wait ( ) ;
165
+
166
+ let postInstallCommmand = `\`cat /tmp/Podfile/testFile.txt > ${ workingFolderPath } /copyTestFile.txt && rm -rf /tmp/Podfile\`` ;
167
+ let podfileContent = `post_install do |installer_representation| ${ postInstallCommmand } end` ;
168
+ fs . writeFile ( path . join ( workingFolderPath , "Podfile" ) , podfileContent ) . wait ( ) ;
169
+
170
+ let podTool = config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ;
171
+ childProcess . spawnFromEvent ( podTool , [ "install" ] , "close" , { cwd : workingFolderPath , stdio : 'inherit' } ) . wait ( ) ;
172
+
173
+ assert . isTrue ( fs . exists ( "/tmp/Podfile" ) . wait ( ) ) ;
174
+ assert . isTrue ( fs . exists ( path . join ( workingFolderPath , "copyTestFile.txt" ) ) . wait ( ) ) ;
175
+ } ) ;
156
176
} ) ;
157
177
} ) ;
158
178
@@ -164,7 +184,6 @@ function createTestInjector() {
164
184
testInjector . register ( "projectService" , ProjectServiceLib . ProjectService ) ;
165
185
testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
166
186
testInjector . register ( "projectTemplatesService" , stubs . ProjectTemplatesService ) ;
167
- testInjector . register ( "projectNameValidator" , mockProjectNameValidator ) ;
168
187
169
188
testInjector . register ( "fs" , fsLib . FileSystem ) ;
170
189
testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
@@ -173,7 +192,9 @@ function createTestInjector() {
173
192
174
193
testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
175
194
testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
176
- testInjector . register ( "config" , { } ) ;
195
+ testInjector . register ( "config" , {
196
+ "USE_POD_SANDBOX" : true
197
+ } ) ;
177
198
testInjector . register ( "lockfile" , stubs . LockFile ) ;
178
199
179
200
testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
0 commit comments