refactor(core): misc changes and integrate review feedback on #19996
closes #20224
This commit is contained in:
parent
a460066972
commit
6e8e3bd248
|
@ -91,7 +91,7 @@ export class JitCompiler {
|
||||||
} else {
|
} else {
|
||||||
const summary = entry as CompileTypeSummary;
|
const summary = entry as CompileTypeSummary;
|
||||||
this._summaryResolver.addSummary(
|
this._summaryResolver.addSummary(
|
||||||
{symbol: summary.type.reference, metadata: null, type: summary})
|
{symbol: summary.type.reference, metadata: null, type: summary});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,10 +229,11 @@ export function main() {
|
||||||
|
|
||||||
const overwrittenValue = {};
|
const overwrittenValue = {};
|
||||||
|
|
||||||
TestBed.overrideProvider(SomeDep, {useFactory: () => overwrittenValue, deps: []});
|
const fixture =
|
||||||
|
TestBed.overrideProvider(SomeDep, {useFactory: () => overwrittenValue, deps: []})
|
||||||
|
.configureTestingModule({providers: [SomeDep], imports: [SomeModule]})
|
||||||
|
.createComponent(SomePublicComponent);
|
||||||
|
|
||||||
const fixture = TestBed.configureTestingModule({providers: [SomeDep], imports: [SomeModule]})
|
|
||||||
.createComponent(SomePublicComponent);
|
|
||||||
expect(fixture.componentInstance.dep).toBe(overwrittenValue);
|
expect(fixture.componentInstance.dep).toBe(overwrittenValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,8 @@ export class TestBed implements Injector {
|
||||||
static overrideProvider(token: any, provider: {
|
static overrideProvider(token: any, provider: {
|
||||||
useFactory: Function,
|
useFactory: Function,
|
||||||
deps: any[],
|
deps: any[],
|
||||||
}): void;
|
}): typeof TestBed;
|
||||||
static overrideProvider(token: any, provider: {useValue: any;}): void;
|
static overrideProvider(token: any, provider: {useValue: any;}): typeof TestBed;
|
||||||
static overrideProvider(token: any, provider: {
|
static overrideProvider(token: any, provider: {
|
||||||
useFactory?: Function,
|
useFactory?: Function,
|
||||||
useValue?: any,
|
useValue?: any,
|
||||||
|
@ -503,7 +503,7 @@ export class TestBed implements Injector {
|
||||||
overrideTemplateUsingTestingModule(component: Type<any>, template: string) {
|
overrideTemplateUsingTestingModule(component: Type<any>, template: string) {
|
||||||
this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template');
|
this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template');
|
||||||
|
|
||||||
@Component({selector: 'empty', template: template})
|
@Component({selector: 'empty', template})
|
||||||
class OverrideComponent {
|
class OverrideComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -752,15 +752,15 @@ export function main() {
|
||||||
/Cannot override template when the test module has already been instantiated/);
|
/Cannot override template when the test module has already been instantiated/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset overrides when the testing modules is resetted', () => {
|
it('should reset overrides when the testing module is resetted', () => {
|
||||||
@Component({selector: 'comp', template: 'a'})
|
@Component({selector: 'comp', template: 'a'})
|
||||||
class MyComponent {
|
class MyComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
TestBed.overrideTemplateUsingTestingModule(MyComponent, 'b');
|
TestBed.overrideTemplateUsingTestingModule(MyComponent, 'b');
|
||||||
TestBed.resetTestingModule();
|
|
||||||
|
|
||||||
const fixture = TestBed.configureTestingModule({declarations: [MyComponent]})
|
const fixture = TestBed.resetTestingModule()
|
||||||
|
.configureTestingModule({declarations: [MyComponent]})
|
||||||
.createComponent(MyComponent);
|
.createComponent(MyComponent);
|
||||||
expect(fixture.nativeElement).toHaveText('a');
|
expect(fixture.nativeElement).toHaveText('a');
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,10 +118,10 @@ export declare class TestBed implements Injector {
|
||||||
static overrideProvider(token: any, provider: {
|
static overrideProvider(token: any, provider: {
|
||||||
useFactory: Function;
|
useFactory: Function;
|
||||||
deps: any[];
|
deps: any[];
|
||||||
}): void;
|
}): typeof TestBed;
|
||||||
static overrideProvider(token: any, provider: {
|
static overrideProvider(token: any, provider: {
|
||||||
useValue: any;
|
useValue: any;
|
||||||
}): void;
|
}): typeof TestBed;
|
||||||
static overrideTemplate(component: Type<any>, template: string): typeof TestBed;
|
static overrideTemplate(component: Type<any>, template: string): typeof TestBed;
|
||||||
static overrideTemplateUsingTestingModule(component: Type<any>, template: string): typeof TestBed;
|
static overrideTemplateUsingTestingModule(component: Type<any>, template: string): typeof TestBed;
|
||||||
/** @experimental */ static resetTestEnvironment(): void;
|
/** @experimental */ static resetTestEnvironment(): void;
|
||||||
|
|
Loading…
Reference in New Issue