Skip to content

Commit

Permalink
refactor(core): misc changes and integrate review feedback on angular…
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Nov 6, 2017
1 parent 9cf9863 commit fc7aff8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions packages/core/test/linker/jit_summaries_integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ export function main() {

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);
});

Expand Down
10 changes: 5 additions & 5 deletions packages/core/testing/src/test_bed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵDepFlags as DepFlags, ɵNodeFlags as NodeFlags, ɵclearOverrides as clearOverrides, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory, ɵoverrideComponentView as overrideComponentView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, StaticProvider, Type, ɵDepFlags as DepFlags, ɵNodeFlags as NodeFlags, ɵclearOverrides as clearOverrides, ɵgetComponentViewDefinitionFactory as getComponentViewDefinitionFactory, ɵoverrideComponentView as overriddenCmpView, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';

import {AsyncTestCompleter} from './async_test_completer';
import {ComponentFixture} from './component_fixture';
Expand Down Expand Up @@ -163,8 +163,8 @@ export class TestBed implements Injector {
static overrideProvider(token: any, provider: {
useFactory: Function,
deps: any[],
}): void;
static overrideProvider(token: any, provider: {useValue: any;}): void;
}): typeof TestBed;
static overrideProvider(token: any, provider: {useValue: any;}): typeof TestBed;
static overrideProvider(token: any, provider: {
useFactory?: Function,
useValue?: any,
Expand Down Expand Up @@ -351,7 +351,7 @@ export class TestBed implements Injector {
}
for (const {component, templateOf} of this._templateOverrides) {
const compFactory = this._compiler.getComponentFactory(templateOf);
overrideComponentView(component, compFactory);
overriddenCmpView(component, compFactory);
}

const ngZone = new NgZone({enableLongStackTrace: true});
Expand Down Expand Up @@ -503,7 +503,7 @@ export class TestBed implements Injector {
overrideTemplateUsingTestingModule(component: Type<any>, template: string) {
this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template');

@Component({selector: 'empty', template: template})
@Component({selector: 'empty', template})
class OverrideComponent {
}

Expand Down
6 changes: 3 additions & 3 deletions packages/platform-browser/test/testing_public_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,15 @@ export function main() {
/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'})
class MyComponent {
}

TestBed.overrideTemplateUsingTestingModule(MyComponent, 'b');
TestBed.resetTestingModule();

const fixture = TestBed.configureTestingModule({declarations: [MyComponent]})
const fixture = TestBed.resetTestingModule()
.configureTestingModule({declarations: [MyComponent]})
.createComponent(MyComponent);
expect(fixture.nativeElement).toHaveText('a');
});
Expand Down

0 comments on commit fc7aff8

Please sign in to comment.