Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 committed Jul 30, 2024
1 parent 02299c8 commit efa3553
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 23 deletions.
1 change: 1 addition & 0 deletions lib/common/test/unit-tests/mobile/device-log-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const createTestInjector = (): IInjector => {
env: {
classicLogs: true,
},
hostProjectModuleName: "app",
});
testInjector.register("loggingLevels", LoggingLevels);
testInjector.register("devicePlatformsConstants", DevicePlatformsConstants);
Expand Down
4 changes: 2 additions & 2 deletions lib/common/test/unit-tests/services/files-hash-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function createTestInjector(): IInjector {
injector.register("fs", FileSystemStub);
injector.register("logger", LoggerStub);
injector.register("filesHashService", FilesHashService);
injector.register("options", {});

return injector;
}
Expand Down Expand Up @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions test/project-files-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function createTestInjector(): IInjector {
},
});

testInjector.register("options", { release: false });
testInjector.register("options", {
release: false,
hostProjectModuleName: "app",
});

return testInjector;
}
Expand All @@ -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);
});

Expand Down
23 changes: 13 additions & 10 deletions test/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down Expand Up @@ -240,9 +242,8 @@ describe("androidProjectService", () => {

compileSdkVersion = 29;

const androidToolsInfo = injector.resolve<IAndroidToolsInfo>(
"androidToolsInfo"
);
const androidToolsInfo =
injector.resolve<IAndroidToolsInfo>("androidToolsInfo");
androidToolsInfo.getToolsInfo = (
config?: IProjectDir
): IAndroidToolsInfoData => {
Expand All @@ -258,9 +259,10 @@ describe("androidProjectService", () => {
"src"
);
beforeEach(() => {
const androidResourcesMigrationService = injector.resolve<
IAndroidResourcesMigrationService
>("androidResourcesMigrationService");
const androidResourcesMigrationService =
injector.resolve<IAndroidResourcesMigrationService>(
"androidResourcesMigrationService"
);
androidResourcesMigrationService.hasMigrated = () => true;
});

Expand Down Expand Up @@ -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<IAndroidResourcesMigrationService>(
"androidResourcesMigrationService"
);
androidResourcesMigrationService.hasMigrated = () => false;
});

Expand Down
17 changes: 11 additions & 6 deletions test/services/log-source-map-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -58,12 +61,14 @@ function toPlatformSep(filePath: string) {
return stringReplaceAll(filePath, "/", path.sep);
}

const testCases: IDictionary<Array<{
caseName: string;
message: string;
expected: string;
runtimeVersion?: string;
}>> = {
const testCases: IDictionary<
Array<{
caseName: string;
message: string;
expected: string;
runtimeVersion?: string;
}>
> = {
android: [
{
caseName: "trace message",
Expand Down
4 changes: 3 additions & 1 deletion test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit efa3553

Please sign in to comment.