fix upgrade tests to not use deprecated API
This commit is contained in:
parent
aa8ab52937
commit
55af9fee49
|
@ -1,25 +1,27 @@
|
||||||
// #docregion routestuff
|
// #docregion routestuff
|
||||||
import { ApplicationRef } from '@angular/core';
|
import { Directive } from '@angular/core';
|
||||||
import { LocationStrategy } from '@angular/common';
|
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
import { HTTP_PROVIDERS } from '@angular/http';
|
||||||
import {
|
import {
|
||||||
ROUTER_PROVIDERS,
|
Router,
|
||||||
|
RouterLink,
|
||||||
|
RootRouter,
|
||||||
|
RouteRegistry,
|
||||||
ROUTER_PRIMARY_COMPONENT
|
ROUTER_PRIMARY_COMPONENT
|
||||||
} from '@angular/router-deprecated';
|
} from '@angular/router-deprecated';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import {
|
import {
|
||||||
describe,
|
describe,
|
||||||
beforeEachProviders,
|
addProviders,
|
||||||
inject,
|
inject,
|
||||||
it,
|
it,
|
||||||
expect,
|
expect,
|
||||||
MockApplicationRef
|
// MockApplicationRef
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { MockLocationStrategy } from '@angular/common/testing';
|
import { SpyLocation } from '@angular/common/testing';
|
||||||
import {
|
import {
|
||||||
TestComponentBuilder,
|
TestComponentBuilder,
|
||||||
ComponentFixture
|
ComponentFixture
|
||||||
} from '@angular/compiler/testing';
|
} from '@angular/core/testing';
|
||||||
|
|
||||||
import { AppComponent } from '../app.component';
|
import { AppComponent } from '../app.component';
|
||||||
import { PhoneListComponent } from './phone-list.component';
|
import { PhoneListComponent } from './phone-list.component';
|
||||||
|
@ -27,6 +29,11 @@ import { Phone, PhoneData } from '../core/phone/phone.service';
|
||||||
|
|
||||||
// #enddocregion routestuff
|
// #enddocregion routestuff
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[routerLink]',
|
||||||
|
inputs: ['routeParams: routerLink', 'target: target']
|
||||||
|
})
|
||||||
|
class RouterLinkMock {}
|
||||||
|
|
||||||
class MockPhone extends Phone {
|
class MockPhone extends Phone {
|
||||||
query(): Observable<PhoneData[]> {
|
query(): Observable<PhoneData[]> {
|
||||||
|
@ -41,19 +48,22 @@ describe('PhoneList', () => {
|
||||||
|
|
||||||
// #docregion routestuff
|
// #docregion routestuff
|
||||||
|
|
||||||
beforeEachProviders(() => [
|
addProviders([
|
||||||
{ provide: Phone, useClass: MockPhone},
|
RouteRegistry,
|
||||||
HTTP_PROVIDERS,
|
{ provide: Router, useClass: RootRouter },
|
||||||
ROUTER_PROVIDERS,
|
|
||||||
{ provide: ApplicationRef, useClass: MockApplicationRef },
|
|
||||||
{ provide: ROUTER_PRIMARY_COMPONENT, useValue: AppComponent },
|
{ provide: ROUTER_PRIMARY_COMPONENT, useValue: AppComponent },
|
||||||
{ provide: LocationStrategy, useClass: MockLocationStrategy},
|
{ provide: Location, useClass: SpyLocation},
|
||||||
|
{ provide: Phone, useClass: MockPhone},
|
||||||
|
HTTP_PROVIDERS
|
||||||
]);
|
]);
|
||||||
// #enddocregion routestuff
|
// #enddocregion routestuff
|
||||||
|
|
||||||
it('should create "phones" model with 2 phones fetched from xhr',
|
it('should create "phones" model with 2 phones fetched from xhr',
|
||||||
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
return tcb.createAsync(PhoneListComponent)
|
return tcb
|
||||||
|
.overrideDirective(AppComponent, RouterLink, RouterLinkMock)
|
||||||
|
.overrideDirective(PhoneListComponent, RouterLink, RouterLinkMock)
|
||||||
|
.createAsync(PhoneListComponent)
|
||||||
.then((fixture: ComponentFixture<PhoneListComponent>) => {
|
.then((fixture: ComponentFixture<PhoneListComponent>) => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let compiled = fixture.debugElement.nativeElement;
|
let compiled = fixture.debugElement.nativeElement;
|
||||||
|
@ -69,7 +79,10 @@ describe('PhoneList', () => {
|
||||||
|
|
||||||
it('should set the default value of orderProp model',
|
it('should set the default value of orderProp model',
|
||||||
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
return tcb.createAsync(PhoneListComponent)
|
return tcb
|
||||||
|
.overrideDirective(AppComponent, RouterLink, RouterLinkMock)
|
||||||
|
.overrideDirective(PhoneListComponent, RouterLink, RouterLinkMock)
|
||||||
|
.createAsync(PhoneListComponent)
|
||||||
.then((fixture: ComponentFixture<PhoneListComponent>) => {
|
.then((fixture: ComponentFixture<PhoneListComponent>) => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let compiled = fixture.debugElement.nativeElement;
|
let compiled = fixture.debugElement.nativeElement;
|
||||||
|
|
Loading…
Reference in New Issue