|
142 | 142 | // console.log("============ PLATFORM SERVICE ========== ", platformService); |
143 | 143 | // }); |
144 | 144 |
|
145 | | -// describe("add platform unit tests", () => { |
146 | | -// describe("#add platform()", () => { |
147 | | -// it("should not fail if platform is not normalized", async () => { |
148 | | -// const fs = testInjector.resolve("fs"); |
149 | | -// fs.exists = () => false; |
150 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
151 | | -// await platformCommandsService.addPlatforms(["Android"], projectData, ""); |
152 | | -// await platformCommandsService.addPlatforms(["ANDROID"], projectData, ""); |
153 | | -// await platformCommandsService.addPlatforms(["AnDrOiD"], projectData, ""); |
154 | | -// await platformCommandsService.addPlatforms(["androiD"], projectData, ""); |
155 | | - |
156 | | -// await platformCommandsService.addPlatforms(["iOS"], projectData, ""); |
157 | | -// await platformCommandsService.addPlatforms(["IOS"], projectData, ""); |
158 | | -// await platformCommandsService.addPlatforms(["IoS"], projectData, ""); |
159 | | -// await platformCommandsService.addPlatforms(["iOs"], projectData, ""); |
160 | | -// }); |
161 | | - |
162 | | -// it("should fail if platform is already installed", async () => { |
163 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
164 | | -// // By default fs.exists returns true, so the platforms directory should exists |
165 | | -// await assert.isRejected(platformCommandsService.addPlatforms(["android"], projectData, ""), "Platform android already added"); |
166 | | -// await assert.isRejected(platformCommandsService.addPlatforms(["ios"], projectData, ""), "Platform ios already added"); |
167 | | -// }); |
168 | | - |
169 | | -// it("should fail if unable to extract runtime package", async () => { |
170 | | -// const fs = testInjector.resolve("fs"); |
171 | | -// fs.exists = () => false; |
172 | | - |
173 | | -// const pacoteService = testInjector.resolve<IPacoteService>("pacoteService"); |
174 | | -// const errorMessage = "Pacote service unable to extract package"; |
175 | | -// pacoteService.extractPackage = async (packageName: string, destinationDirectory: string, options?: IPacoteExtractOptions): Promise<void> => { |
176 | | -// throw new Error(errorMessage); |
177 | | -// }; |
178 | | - |
179 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
180 | | -// await assert.isRejected(platformCommandsService.addPlatforms(["android"], projectData, ""), errorMessage); |
181 | | -// }); |
182 | | - |
183 | | -// it("fails when path passed to frameworkPath does not exist", async () => { |
184 | | -// const fs = testInjector.resolve("fs"); |
185 | | -// fs.exists = () => false; |
186 | | - |
187 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
188 | | -// const frameworkPath = "invalidPath"; |
189 | | -// const errorMessage = format(AddPlaformErrors.InvalidFrameworkPathStringFormat, frameworkPath); |
190 | | -// await assert.isRejected(platformCommandsService.addPlatforms(["android"], projectData, frameworkPath), errorMessage); |
191 | | -// }); |
192 | | - |
193 | | -// const assertCorrectDataIsPassedToPacoteService = async (versionString: string): Promise<void> => { |
194 | | -// const fs = testInjector.resolve("fs"); |
195 | | -// fs.exists = () => false; |
196 | | - |
197 | | -// const pacoteService = testInjector.resolve<IPacoteService>("pacoteService"); |
198 | | -// let packageNamePassedToPacoteService = ""; |
199 | | -// pacoteService.extractPackage = async (name: string, destinationDirectory: string, options?: IPacoteExtractOptions): Promise<void> => { |
200 | | -// packageNamePassedToPacoteService = name; |
201 | | -// }; |
202 | | - |
203 | | -// const platformsData = testInjector.resolve<IPlatformsData>("platformsData"); |
204 | | -// const packageName = "packageName"; |
205 | | -// platformsData.getPlatformData = (platform: string, pData: IProjectData): IPlatformData => { |
206 | | -// return { |
207 | | -// frameworkPackageName: packageName, |
208 | | -// platformNameLowerCase: "", |
209 | | -// platformProjectService: new stubs.PlatformProjectServiceStub(), |
210 | | -// projectRoot: "", |
211 | | -// normalizedPlatformName: "", |
212 | | -// appDestinationDirectoryPath: "", |
213 | | -// getBuildOutputPath: () => "", |
214 | | -// getValidBuildOutputData: (buildOptions: IBuildOutputOptions) => ({ packageNames: [] }), |
215 | | -// frameworkFilesExtensions: [], |
216 | | -// relativeToFrameworkConfigurationFilePath: "", |
217 | | -// fastLivesyncFileExtensions: [] |
218 | | -// }; |
219 | | -// }; |
220 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
221 | | - |
222 | | -// await platformCommandsService.addPlatforms(["android"], projectData, ""); |
223 | | -// assert.equal(packageNamePassedToPacoteService, `${packageName}@${versionString}`); |
224 | | -// await platformCommandsService.addPlatforms(["ios"], projectData, ""); |
225 | | -// assert.equal(packageNamePassedToPacoteService, `${packageName}@${versionString}`); |
226 | | -// }; |
227 | | -// it("should respect platform version in package.json's nativescript key", async () => { |
228 | | -// const versionString = "2.5.0"; |
229 | | -// const nsValueObject: any = { |
230 | | -// [VERSION_STRING]: versionString |
231 | | -// }; |
232 | | -// const projectDataService = testInjector.resolve("projectDataService"); |
233 | | -// projectDataService.getNSValue = () => nsValueObject; |
234 | | - |
235 | | -// await assertCorrectDataIsPassedToPacoteService(versionString); |
236 | | -// }); |
237 | | - |
238 | | -// it("should install latest platform if no information found in package.json's nativescript key", async () => { |
239 | | - |
240 | | -// const projectDataService = testInjector.resolve("projectDataService"); |
241 | | -// projectDataService.getNSValue = (): any => null; |
242 | | - |
243 | | -// const latestCompatibleVersion = "1.0.0"; |
244 | | -// const packageInstallationManager = testInjector.resolve<IPackageInstallationManager>("packageInstallationManager"); |
245 | | -// packageInstallationManager.getLatestCompatibleVersion = async (packageName: string, referenceVersion?: string): Promise<string> => { |
246 | | -// return latestCompatibleVersion; |
247 | | -// }; |
248 | | - |
249 | | -// await assertCorrectDataIsPassedToPacoteService(latestCompatibleVersion); |
250 | | -// }); |
251 | | - |
252 | | -// // Workflow: tns preview; tns platform add |
253 | | -// it(`should add platform when only .js part of the platform has already been added (nativePlatformStatus is ${constants.NativePlatformStatus.requiresPlatformAdd})`, async () => { |
254 | | -// const fs = testInjector.resolve("fs"); |
255 | | -// fs.exists = () => true; |
256 | | -// const projectChangesService = testInjector.resolve("projectChangesService"); |
257 | | -// projectChangesService.getPrepareInfo = () => ({ nativePlatformStatus: constants.NativePlatformStatus.requiresPlatformAdd }); |
258 | | -// const projectData = testInjector.resolve("projectData"); |
259 | | -// let isJsPlatformAdded = false; |
260 | | -// const preparePlatformJSService = testInjector.resolve("preparePlatformJSService"); |
261 | | -// preparePlatformJSService.addPlatform = async () => isJsPlatformAdded = true; |
262 | | -// let isNativePlatformAdded = false; |
263 | | -// const preparePlatformService = testInjector.resolve("preparePlatformService"); |
264 | | -// preparePlatformService.addNativePlatform = async () => isNativePlatformAdded = true; |
265 | | - |
266 | | -// await platformCommandsService.addPlatforms(["android"], projectData, ""); |
267 | | - |
268 | | -// assert.isTrue(isJsPlatformAdded); |
269 | | -// assert.isTrue(isNativePlatformAdded); |
270 | | -// }); |
271 | | - |
272 | | -// // Workflow: tns platform add; tns platform add |
273 | | -// it("shouldn't add platform when platforms folder exist and no .nsprepare file", async () => { |
274 | | -// const fs = testInjector.resolve("fs"); |
275 | | -// fs.exists = () => true; |
276 | | -// const projectChangesService = testInjector.resolve("projectChangesService"); |
277 | | -// projectChangesService.getPrepareInfo = () => <any>null; |
278 | | -// const projectData = testInjector.resolve("projectData"); |
279 | | - |
280 | | -// await assert.isRejected(platformCommandsService.addPlatforms(["android"], projectData, ""), "Platform android already added"); |
281 | | -// }); |
282 | | - |
283 | | -// // Workflow: tns run; tns platform add |
284 | | -// it(`shouldn't add platform when both native and .js parts of the platform have already been added (nativePlatformStatus is ${constants.NativePlatformStatus.alreadyPrepared})`, async () => { |
285 | | -// const fs = testInjector.resolve("fs"); |
286 | | -// fs.exists = () => true; |
287 | | -// const projectChangesService = testInjector.resolve("projectChangesService"); |
288 | | -// projectChangesService.getPrepareInfo = () => ({ nativePlatformStatus: constants.NativePlatformStatus.alreadyPrepared }); |
289 | | -// const projectData = testInjector.resolve("projectData"); |
290 | | - |
291 | | -// await assert.isRejected(platformCommandsService.addPlatforms(["android"], projectData, ""), "Platform android already added"); |
292 | | -// }); |
293 | | -// }); |
294 | | -// }); |
295 | | - |
296 | | -// describe("remove platform unit tests", () => { |
297 | | -// it("should fail when platforms are not added", async () => { |
298 | | -// const ExpectedErrorsCaught = 2; |
299 | | -// let errorsCaught = 0; |
300 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
301 | | -// testInjector.resolve("fs").exists = () => false; |
302 | | - |
303 | | -// try { |
304 | | -// await platformCommandsService.removePlatforms(["android"], projectData); |
305 | | -// } catch (e) { |
306 | | -// errorsCaught++; |
307 | | -// } |
308 | | - |
309 | | -// try { |
310 | | -// await platformCommandsService.removePlatforms(["ios"], projectData); |
311 | | -// } catch (e) { |
312 | | -// errorsCaught++; |
313 | | -// } |
314 | | - |
315 | | -// assert.isTrue(errorsCaught === ExpectedErrorsCaught); |
316 | | -// }); |
317 | | -// it("shouldn't fail when platforms are added", async () => { |
318 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
319 | | -// testInjector.resolve("fs").exists = () => false; |
320 | | -// await platformCommandsService.addPlatforms(["android"], projectData, ""); |
321 | | - |
322 | | -// testInjector.resolve("fs").exists = () => true; |
323 | | -// await platformCommandsService.removePlatforms(["android"], projectData); |
324 | | -// }); |
325 | | -// }); |
326 | | - |
327 | | -// describe("clean platform unit tests", () => { |
328 | | -// it("should preserve the specified in the project nativescript version", async () => { |
329 | | -// const versionString = "2.4.1"; |
330 | | -// const fs = testInjector.resolve("fs"); |
331 | | -// fs.exists = () => false; |
332 | | - |
333 | | -// const nsValueObject: any = {}; |
334 | | -// nsValueObject[VERSION_STRING] = versionString; |
335 | | -// const projectDataService = testInjector.resolve("projectDataService"); |
336 | | -// projectDataService.getNSValue = () => nsValueObject; |
337 | | - |
338 | | -// const packageInstallationManager = testInjector.resolve("packageInstallationManager"); |
339 | | -// packageInstallationManager.install = (packageName: string, packageDir: string, options: INpmInstallOptions) => { |
340 | | -// assert.deepEqual(options.version, versionString); |
341 | | -// return ""; |
342 | | -// }; |
343 | | - |
344 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
345 | | -// platformCommandsService.removePlatforms = (platforms: string[], prjctData: IProjectData): Promise<void> => { |
346 | | -// nsValueObject[VERSION_STRING] = undefined; |
347 | | -// return Promise.resolve(); |
348 | | -// }; |
349 | | - |
350 | | -// await platformCommandsService.cleanPlatforms(["android"], projectData, ""); |
351 | | - |
352 | | -// nsValueObject[VERSION_STRING] = versionString; |
353 | | -// await platformCommandsService.cleanPlatforms(["ios"], projectData, ""); |
354 | | -// }); |
355 | | -// }); |
356 | | - |
357 | | -// // TODO: Commented as it doesn't seem correct. Check what's the case and why it's been expected to fail. |
358 | | -// // describe("list platform unit tests", () => { |
359 | | -// // it("fails when platforms are not added", () => { |
360 | | -// // assert.throws(async () => await platformService.getAvailablePlatforms()); |
361 | | -// // }); |
362 | | -// // }); |
363 | | - |
364 | | -// describe("update Platform", () => { |
365 | | -// describe("#updatePlatform(platform)", () => { |
366 | | -// it("should fail when the versions are the same", async () => { |
367 | | -// const packageInstallationManager: IPackageInstallationManager = testInjector.resolve("packageInstallationManager"); |
368 | | -// packageInstallationManager.getLatestVersion = async () => "0.2.0"; |
369 | | -// const projectData: IProjectData = testInjector.resolve("projectData"); |
370 | | - |
371 | | -// await assert.isRejected(platformCommandsService.updatePlatforms(["android"], projectData)); |
372 | | -// }); |
373 | | -// }); |
374 | | -// }); |
375 | | - |
376 | 145 | // // TODO: check this tests with QAs |
377 | 146 | // // describe("prepare platform unit tests", () => { |
378 | 147 | // // let fs: IFileSystem; |
|
532 | 301 | // // fs.writeFile(fileToUpdate, content); |
533 | 302 | // // } |
534 | 303 |
|
535 | | -// // it("should process only files in app folder when preparing for iOS platform", async () => { |
536 | | -// // await testPreparePlatform("iOS"); |
537 | | -// // }); |
538 | | - |
539 | | -// // it("should process only files in app folder when preparing for Android platform", async () => { |
540 | | -// // await testPreparePlatform("Android"); |
541 | | -// // }); |
542 | | - |
543 | | -// // it("should process only files in app folder when preparing for iOS platform", async () => { |
544 | | -// // await testPreparePlatform("iOS", true); |
545 | | -// // }); |
546 | | - |
547 | | -// // it("should process only files in app folder when preparing for Android platform", async () => { |
548 | | -// // await testPreparePlatform("Android", true); |
549 | | -// // }); |
550 | | - |
551 | 304 | // // function getDefaultFolderVerificationData(platform: string, appDestFolderPath: string) { |
552 | 305 | // // const data: any = {}; |
553 | 306 | // // if (platform.toLowerCase() === "ios") { |
|
0 commit comments