Permalink
Browse files

fix(dialog-service): fix no fail for undefined moduleId

fix #312
  • Loading branch information...
StrahilKazlachev committed Jul 1, 2017
1 parent fd58f2a commit e90a9d8650bc7314242cbedd0d5c9fab2650e08f
Showing with 11 additions and 1 deletion.
  1. +5 −1 src/dialog-service.ts
  2. +6 −0 test/unit/dialog-service.spec.ts
View
@@ -78,7 +78,11 @@ export class DialogService {
private ensureViewModel(compositionContext: CompositionContext): Promise<CompositionContext> {
if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
const moduleId = Origin.get(compositionContext.viewModel).moduleId;
if (!moduleId) {
return Promise.reject(new Error(`Can not resolve "moduleId" of "${compositionContext.viewModel.name}".`));
}
compositionContext.viewModel = moduleId;
}
if (typeof compositionContext.viewModel === 'string') {
@@ -130,6 +130,12 @@ describe('DialogService', () => {
done();
});
it('should get rejected when the "moduleId" of the provided view model can not be resolved ', async done => {
const settings = { viewModel: class {} };
await _failure(() => dialogService.open(settings), done);
done();
});
it('propagates errors', async done => {
const expectdError = new Error('Expected error.');
spyOn(TestElement.prototype, 'canActivate').and.callFake(() => { throw expectdError; });

0 comments on commit e90a9d8

Please sign in to comment.