Skip to content

Commit

Permalink
fixup! fix(ivy): ensure overrides for 'multi: true' only appear once …
Browse files Browse the repository at this point in the history
…in final providers
  • Loading branch information
atscott committed Oct 22, 2019
1 parent 1cd2b43 commit 4aef656
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/core/test/test_bed_spec.ts
Expand Up @@ -273,7 +273,6 @@ describe('TestBed', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MyModule, MyModule2],
providers: [{provide: multiToken, useValue: ['override'], multi: true}]
});
});

Expand Down Expand Up @@ -311,7 +310,7 @@ describe('TestBed', () => {
static forRoot() {
return {
ngModule: MyMod,
providers: [[{provide: TOKEN, multi: true, useValue: 'forRootValue'}]]
providers: [{provide: TOKEN, multi: true, useValue: 'forRootValue'}]
};
}
}
Expand Down
11 changes: 9 additions & 2 deletions packages/core/testing/src/r3_test_bed_compiler.ts
Expand Up @@ -381,8 +381,15 @@ export class R3TestBedCompiler {

// Apply provider overrides to imported modules recursively
const moduleDef: any = (moduleType as any)[NG_MOD_DEF];
for (const importType of moduleDef.imports) {
this.applyProviderOverridesToModule(importType);
for (const importedModule of moduleDef.imports) {
this.applyProviderOverridesToModule(importedModule);
}
// Also override the providers on any ModuleWithProviders imports since those don't appear in
// the moduleDef.
for (const importedModule of flatten(injectorDef.imports)) {
if (isModuleWithProviders(importedModule)) {
importedModule.providers = this.getOverriddenProviders(importedModule.providers);
}
}
}
}
Expand Down

0 comments on commit 4aef656

Please sign in to comment.