Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/services/project-changes-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class ProjectChangesService implements IProjectChangesService {

public setNativePlatformStatus(platform: string, projectData: IProjectData, addedPlatform: IAddedNativePlatform): void {
this._prepareInfo = this._prepareInfo || this.getPrepareInfo(platform, projectData);
if (this._prepareInfo) {
if (this._prepareInfo && addedPlatform.nativePlatformStatus === NativePlatformStatus.alreadyPrepared) {
this._prepareInfo.nativePlatformStatus = addedPlatform.nativePlatformStatus;
} else {
this._prepareInfo = {
Expand Down
46 changes: 46 additions & 0 deletions test/project-changes-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,51 @@ describe("Project Changes Service Tests", () => {
assert.deepEqual(actualPrepareInfo, { nativePlatformStatus: Constants.NativePlatformStatus.requiresPrepare });
}
});

it(`shouldn't reset prepare info when native platform status is ${Constants.NativePlatformStatus.alreadyPrepared} and there is existing prepare info`, async () => {
for (const platform of ["ios", "android"]) {
await serviceTest.projectChangesService.checkForChanges({
platform,
projectData: serviceTest.projectData,
projectChangesOptions: {
bundle: false,
release: false,
provision: undefined,
teamId: undefined,
useHotModuleReload: false
}
});
serviceTest.projectChangesService.savePrepareInfo(platform, serviceTest.projectData);
const prepareInfo = serviceTest.projectChangesService.getPrepareInfo(platform, serviceTest.projectData);

serviceTest.projectChangesService.setNativePlatformStatus(platform, serviceTest.projectData, { nativePlatformStatus: Constants.NativePlatformStatus.alreadyPrepared });

const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(platform, serviceTest.projectData);
prepareInfo.nativePlatformStatus = Constants.NativePlatformStatus.alreadyPrepared;
assert.deepEqual(actualPrepareInfo, prepareInfo);
}
});

_.each([Constants.NativePlatformStatus.requiresPlatformAdd, Constants.NativePlatformStatus.requiresPrepare], nativePlatformStatus => {
it(`should reset prepare info when native platform status is ${nativePlatformStatus} and there is existing prepare info`, async () => {
for (const platform of ["ios", "android"]) {
await serviceTest.projectChangesService.checkForChanges({
platform,
projectData: serviceTest.projectData,
projectChangesOptions: {
bundle: false,
release: false,
provision: undefined,
teamId: undefined,
useHotModuleReload: false
}
});
serviceTest.projectChangesService.setNativePlatformStatus(platform, serviceTest.projectData, { nativePlatformStatus: nativePlatformStatus });

const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(platform, serviceTest.projectData);
assert.deepEqual(actualPrepareInfo, { nativePlatformStatus: nativePlatformStatus });
}
});
});
});
});