Skip to content

Commit 6f2df11

Browse files
KristianDDKristian D. Dimitrov
authored and
Kristian D. Dimitrov
committed
Fix ui tests for platform service and safeguard missing id.
1 parent 2162950 commit 6f2df11

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/project-data.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class ProjectData implements IProjectData {
5656

5757
public initializeProjectData(projectDir?: string): void {
5858
projectDir = projectDir || this.$projectHelper.projectDir;
59+
5960
// If no project found, projectDir should be null
6061
if (projectDir) {
6162
const projectFilePath = path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME);
@@ -79,10 +80,7 @@ export class ProjectData implements IProjectData {
7980
this.projectFilePath = projectFilePath;
8081
this.appDirectoryPath = path.join(projectDir, constants.APP_FOLDER_NAME);
8182
this.appResourcesDirectoryPath = path.join(projectDir, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME);
82-
this.projectIdentifiers = {
83-
android: data.id.android || data.id,
84-
ios: data.id.ios || data.id
85-
};
83+
this.projectIdentifiers = this.getProjectIdentifiers(data.id);
8684
this.dependencies = fileContent.dependencies;
8785
this.devDependencies = fileContent.devDependencies;
8886
this.projectType = this.getProjectType();
@@ -99,6 +97,25 @@ export class ProjectData implements IProjectData {
9997
this.$errors.fail("No project found at or above '%s' and neither was a --path specified.", projectDir || this.$options.path || currentDir);
10098
}
10199

100+
private getProjectIdentifiers(data :any): IProjectIdentifier {
101+
let identifier: IProjectIdentifier;
102+
data = data || "";
103+
104+
if(typeof data === "string") {
105+
identifier = {
106+
android: data,
107+
ios: data
108+
};
109+
} else {
110+
identifier = {
111+
android: data.android || "",
112+
ios: data.ios || ""
113+
};
114+
}
115+
116+
return identifier;
117+
}
118+
102119
private getProjectType(): string {
103120
let detectedProjectType = _.find(ProjectData.PROJECT_TYPES, (projectType) => projectType.isDefaultProjectType).type;
104121

test/platform-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ describe('Platform Service Tests', () => {
367367
testInjector = createTestInjector();
368368
testInjector.register("fs", fsLib.FileSystem);
369369
fs = testInjector.resolve("fs");
370+
testInjector.resolve("projectData").initializeProjectData();
370371
});
371372

372373
function prepareDirStructure() {

0 commit comments

Comments
 (0)