@@ -39,21 +39,20 @@ class ProjectIntegrationTest {
3939 return projectService . createProject ( projectName ) ;
4040 }
4141
42- public getDefaultTemplatePath ( ) : IFuture < string > {
42+ public getDefaultTemplatePath ( templateName : string ) : IFuture < string > {
4343 return ( ( ) => {
4444 let npmInstallationManager = this . testInjector . resolve ( "npmInstallationManager" ) ;
4545 let fs = this . testInjector . resolve ( "fs" ) ;
4646
47- let defaultTemplatePackageName = "tns-template-hello-world" ;
4847 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 ( ) ;
5150
5251 if ( ! fs . exists ( path . join ( defaultTemplatePath , latestVersion ) ) . wait ( ) ) {
53- npmInstallationManager . addToCache ( defaultTemplatePackageName , latestVersion ) . wait ( ) ;
52+ npmInstallationManager . addToCache ( templateName , latestVersion ) . wait ( ) ;
5453 }
5554 if ( ! fs . exists ( path . join ( defaultTemplatePath , latestVersion , "package" , "app" ) ) . wait ( ) ) {
56- npmInstallationManager . cacheUnpack ( defaultTemplatePackageName , latestVersion ) . wait ( ) ;
55+ npmInstallationManager . cacheUnpack ( templateName , latestVersion ) . wait ( ) ;
5756 }
5857
5958 return path . join ( defaultTemplatePath , latestVersion , "package" ) ;
@@ -118,7 +117,6 @@ class ProjectIntegrationTest {
118117 this . testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
119118 this . testInjector . register ( "npm" , NpmLib . NodePackageManager ) ;
120119 this . testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
121- this . testInjector . register ( "config" , { } ) ;
122120 this . testInjector . register ( "lockfile" , stubs . LockFile ) ;
123121
124122 this . testInjector . register ( "options" , optionsLib . Options ) ;
@@ -135,7 +133,7 @@ describe("Project Service Tests", () => {
135133 let options = projectIntegrationTest . testInjector . resolve ( "options" ) ;
136134
137135 options . path = tempFolder ;
138- options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( ) . wait ( ) ;
136+ options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( "tns-template-hello-world" ) . wait ( ) ;
139137
140138 projectIntegrationTest . createProject ( projectName ) . wait ( ) ;
141139 projectIntegrationTest . assertProject ( tempFolder , projectName , "org.nativescript.myapp" ) . wait ( ) ;
@@ -147,12 +145,34 @@ describe("Project Service Tests", () => {
147145 let options = projectIntegrationTest . testInjector . resolve ( "options" ) ;
148146
149147 options . path = tempFolder ;
150- options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( ) . wait ( ) ;
148+ options . copyFrom = projectIntegrationTest . getDefaultTemplatePath ( "tns-template-hello-world" ) . wait ( ) ;
151149 options . appid = "my.special.id" ;
152150
153151 projectIntegrationTest . createProject ( projectName ) . wait ( ) ;
154152 projectIntegrationTest . assertProject ( tempFolder , projectName , options . appid ) . wait ( ) ;
155153 } ) ;
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+ } ) ;
156176 } ) ;
157177} ) ;
158178
@@ -164,7 +184,6 @@ function createTestInjector() {
164184 testInjector . register ( "projectService" , ProjectServiceLib . ProjectService ) ;
165185 testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
166186 testInjector . register ( "projectTemplatesService" , stubs . ProjectTemplatesService ) ;
167- testInjector . register ( "projectNameValidator" , mockProjectNameValidator ) ;
168187
169188 testInjector . register ( "fs" , fsLib . FileSystem ) ;
170189 testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
@@ -173,7 +192,9 @@ function createTestInjector() {
173192
174193 testInjector . register ( "npmInstallationManager" , NpmInstallationManagerLib . NpmInstallationManager ) ;
175194 testInjector . register ( "httpClient" , HttpClientLib . HttpClient ) ;
176- testInjector . register ( "config" , { } ) ;
195+ testInjector . register ( "config" , {
196+ "USE_POD_SANDBOX" : true
197+ } ) ;
177198 testInjector . register ( "lockfile" , stubs . LockFile ) ;
178199
179200 testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
0 commit comments