Skip to content

Commit

Permalink
fix tests and make registration in legacy platform possible
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Dec 31, 2019
1 parent b75d59c commit bb09ea9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/legacy/ui/public/new_platform/new_platform.karma_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export const npSetup = {
featureCatalogue: {
register: sinon.fake(),
},
environment: {
update: sinon.fake(),
},
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,5 @@ describe('EnvironmentService', () => {
setup.update({ ml: false, apmUi: true });
expect(service.start().get()).toEqual({ ml: false, cloud: true, apmUi: true });
});

test('fails if trying to update state after setup phase', () => {
const service = new EnvironmentService();
const setup = service.setup();
service.start();
expect(() => {
setup.update({ ml: true });
}).toThrow();
});
});
});
8 changes: 0 additions & 8 deletions src/plugins/home/public/services/environment/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export interface Environment {
}

export class EnvironmentService {
private frozen = false;
private environment = {
cloud: false,
apmUi: false,
Expand All @@ -51,19 +50,12 @@ export class EnvironmentService {
* @param update
*/
update: (update: Partial<Environment>) => {
if (this.frozen) {
throw new Error(
'Environment already frozen, did you try to change the environment in the start phase?'
);
}
this.environment = Object.assign({}, this.environment, update);
},
};
}

public start() {
this.frozen = true;
Object.freeze(this.environment);
return {
/**
* Retrieve the current environment home is running in. This API is only intended for internal
Expand Down

0 comments on commit bb09ea9

Please sign in to comment.