From efa355366ae3d52d3308e25f4078a484ff6defa9 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 30 Jul 2024 21:29:55 +0200 Subject: [PATCH] chore: fix tests --- .../unit-tests/mobile/device-log-provider.ts | 1 + .../unit-tests/services/files-hash-service.ts | 4 ++-- package-lock.json | 4 ++-- test/project-files-provider.ts | 8 +++++-- test/services/android-project-service.ts | 23 +++++++++++-------- test/services/log-source-map-service.ts | 17 +++++++++----- test/stubs.ts | 4 +++- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/lib/common/test/unit-tests/mobile/device-log-provider.ts b/lib/common/test/unit-tests/mobile/device-log-provider.ts index 736a419b95..022524d329 100644 --- a/lib/common/test/unit-tests/mobile/device-log-provider.ts +++ b/lib/common/test/unit-tests/mobile/device-log-provider.ts @@ -36,6 +36,7 @@ const createTestInjector = (): IInjector => { env: { classicLogs: true, }, + hostProjectModuleName: "app", }); testInjector.register("loggingLevels", LoggingLevels); testInjector.register("devicePlatformsConstants", DevicePlatformsConstants); diff --git a/lib/common/test/unit-tests/services/files-hash-service.ts b/lib/common/test/unit-tests/services/files-hash-service.ts index 6181c3d637..e4cda33d2d 100644 --- a/lib/common/test/unit-tests/services/files-hash-service.ts +++ b/lib/common/test/unit-tests/services/files-hash-service.ts @@ -22,6 +22,7 @@ function createTestInjector(): IInjector { injector.register("fs", FileSystemStub); injector.register("logger", LoggerStub); injector.register("filesHashService", FilesHashService); + injector.register("options", {}); return injector; } @@ -74,8 +75,7 @@ describe("filesHashService", () => { expectedChanges: { file7: "hash7" }, }, { - name: - "should return changes when a file is added and a file is removed from oldHashes", + name: "should return changes when a file is added and a file is removed from oldHashes", newHashes: addFileHashes({ file9: "hash9" }), oldHashes: removeFileHashes({ file1: "hash1" }), expectedChanges: { file1: "hash1", file9: "hash9" }, diff --git a/package-lock.json b/package-lock.json index 9d85ecf941..fe8c34a647 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nativescript", - "version": "8.8.0-embed.2", + "version": "8.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nativescript", - "version": "8.8.0-embed.2", + "version": "8.8.0", "bundleDependencies": [ "@npmcli/move-file", "stringify-package" diff --git a/test/project-files-provider.ts b/test/project-files-provider.ts index 8d400bd2d0..a5edfc2314 100644 --- a/test/project-files-provider.ts +++ b/test/project-files-provider.ts @@ -33,7 +33,10 @@ function createTestInjector(): IInjector { }, }); - testInjector.register("options", { release: false }); + testInjector.register("options", { + release: false, + hostProjectModuleName: "app", + }); return testInjector; } @@ -48,7 +51,8 @@ describe("project-files-provider", () => { projectData = testInjector.resolve("projectData"); projectData.projectDir = projectDir; projectData.appDirectoryPath = projectData.getAppDirectoryPath(); - projectData.appResourcesDirectoryPath = projectData.getAppResourcesDirectoryPath(); + projectData.appResourcesDirectoryPath = + projectData.getAppResourcesDirectoryPath(); projectFilesProvider = testInjector.resolve(ProjectFilesProvider); }); diff --git a/test/services/android-project-service.ts b/test/services/android-project-service.ts index ed199e47ca..1961548012 100644 --- a/test/services/android-project-service.ts +++ b/test/services/android-project-service.ts @@ -41,7 +41,9 @@ const createTestInjector = (): IInjector => { testInjector.register("androidPluginBuildService", {}); testInjector.register("errors", stubs.ErrorsStub); testInjector.register("logger", stubs.LoggerStub); - testInjector.register("options", {}); + testInjector.register("options", { + hostProjectModuleName: "app", + }); testInjector.register("projectData", stubs.ProjectDataStub); testInjector.register("androidToolsInfo", { getToolsInfo: () => { @@ -240,9 +242,8 @@ describe("androidProjectService", () => { compileSdkVersion = 29; - const androidToolsInfo = injector.resolve( - "androidToolsInfo" - ); + const androidToolsInfo = + injector.resolve("androidToolsInfo"); androidToolsInfo.getToolsInfo = ( config?: IProjectDir ): IAndroidToolsInfoData => { @@ -258,9 +259,10 @@ describe("androidProjectService", () => { "src" ); beforeEach(() => { - const androidResourcesMigrationService = injector.resolve< - IAndroidResourcesMigrationService - >("androidResourcesMigrationService"); + const androidResourcesMigrationService = + injector.resolve( + "androidResourcesMigrationService" + ); androidResourcesMigrationService.hasMigrated = () => true; }); @@ -329,9 +331,10 @@ describe("androidProjectService", () => { describe("when old Android App_Resources structure is detected (post {N} 4.0 structure)", () => { beforeEach(() => { - const androidResourcesMigrationService = injector.resolve< - IAndroidResourcesMigrationService - >("androidResourcesMigrationService"); + const androidResourcesMigrationService = + injector.resolve( + "androidResourcesMigrationService" + ); androidResourcesMigrationService.hasMigrated = () => false; }); diff --git a/test/services/log-source-map-service.ts b/test/services/log-source-map-service.ts index 6e15615248..eb7a22037d 100644 --- a/test/services/log-source-map-service.ts +++ b/test/services/log-source-map-service.ts @@ -50,6 +50,9 @@ function createTestInjector(): IInjector { testInjector.register("devicePlatformsConstants", DevicePlatformsConstants); testInjector.register("logger", LoggerStub); testInjector.register("logSourceMapService", LogSourceMapService); + testInjector.register("options", { + hostProjectModuleName: "app", + }); return testInjector; } @@ -58,12 +61,14 @@ function toPlatformSep(filePath: string) { return stringReplaceAll(filePath, "/", path.sep); } -const testCases: IDictionary> = { +const testCases: IDictionary< + Array<{ + caseName: string; + message: string; + expected: string; + runtimeVersion?: string; + }> +> = { android: [ { caseName: "trace message", diff --git a/test/stubs.ts b/test/stubs.ts index 39f1f012b5..02f0d06529 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -1470,7 +1470,9 @@ export class InjectorStub extends Yok implements IInjector { this.register("androidToolsInfo", AndroidToolsInfoStub); this.register("logger", LoggerStub); this.register("errors", ErrorsStub); - this.register("options", {}); + this.register("options", { + hostProjectModuleName: "app", + }); this.register("config", {}); this.register("staticConfig", {}); this.register("hooksService", HooksServiceStub);