diff --git a/packages/core/testing/src/resolvers.ts b/packages/core/testing/src/resolvers.ts index 262d387d02..2a15dd7bc5 100644 --- a/packages/core/testing/src/resolvers.ts +++ b/packages/core/testing/src/resolvers.ts @@ -22,14 +22,18 @@ export interface Resolver { resolve(type: Type): T|null; } * Allows to override ivy metadata for tests (via the `TestBed`). */ abstract class OverrideResolver implements Resolver { - private overrides = new Map, MetadataOverride>(); + private overrides = new Map, MetadataOverride[]>(); private resolved = new Map, T|null>(); abstract get type(): any; setOverrides(overrides: Array<[Type, MetadataOverride]>) { this.overrides.clear(); - overrides.forEach(([type, override]) => this.overrides.set(type, override)); + overrides.forEach(([type, override]) => { + const overrides = this.overrides.get(type) || []; + overrides.push(override); + this.overrides.set(type, overrides); + }); } getAnnotation(type: Type): T|null { @@ -42,10 +46,12 @@ abstract class OverrideResolver implements Resolver { if (!resolved) { resolved = this.getAnnotation(type); if (resolved) { - const override = this.overrides.get(type); - if (override) { + const overrides = this.overrides.get(type); + if (overrides) { const overrider = new MetadataOverrider(); - resolved = overrider.overrideMetadata(this.type, resolved, override); + overrides.forEach(override => { + resolved = overrider.overrideMetadata(this.type, resolved !, override); + }); } } this.resolved.set(type, resolved); diff --git a/packages/platform-browser/test/testing_public_spec.ts b/packages/platform-browser/test/testing_public_spec.ts index 12445154f3..e41fbcbbcb 100644 --- a/packages/platform-browser/test/testing_public_spec.ts +++ b/packages/platform-browser/test/testing_public_spec.ts @@ -388,12 +388,11 @@ class CompWithUrlTemplate { .overridePipe(SomePipe, {set: {name: 'somePipe'}}) .overridePipe(SomePipe, {add: {pure: false}}); }); - fixmeIvy('FW-788: Support metadata override in TestBed (for AOT-compiled components)') - .it('should work', () => { - const compFixture = TestBed.createComponent(SomeComponent); - compFixture.detectChanges(); - expect(compFixture.nativeElement).toHaveText('transformed hello'); - }); + it('should work', () => { + const compFixture = TestBed.createComponent(SomeComponent); + compFixture.detectChanges(); + expect(compFixture.nativeElement).toHaveText('transformed hello'); + }); }); describe('template', () => {