
committed by
Miško Hevery

parent
1e9cd95f5c
commit
1a75934cc0
@ -17,11 +17,11 @@ import { By } from '@angular/platform-browser';
|
||||
import { DebugElement, Type } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { AboutComponent } from './about.component';
|
||||
import { DashboardHeroComponent } from './dashboard/dashboard-hero.component';
|
||||
import { TwainService } from './shared/twain.service';
|
||||
import { AppModule } from './app.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { AboutComponent } from './about.component';
|
||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
||||
import { TwainService } from './shared/twain.service';
|
||||
|
||||
let comp: AppComponent;
|
||||
let fixture: ComponentFixture<AppComponent>;
|
||||
@ -41,7 +41,7 @@ describe('AppComponent & RouterTestingModule', () => {
|
||||
it('should navigate to "Dashboard" immediately', fakeAsync(() => {
|
||||
createComponent();
|
||||
expect(location.path()).toEqual('/dashboard', 'after initialNavigation()');
|
||||
expectElementOf(DashboardHeroComponent);
|
||||
expectElementOf(DashboardComponent);
|
||||
}));
|
||||
|
||||
it('should navigate to "About" on click', fakeAsync(() => {
|
||||
@ -52,17 +52,12 @@ describe('AppComponent & RouterTestingModule', () => {
|
||||
advance();
|
||||
expectPathToBe('/about');
|
||||
expectElementOf(AboutComponent);
|
||||
|
||||
page.expectEvents([
|
||||
[r.NavigationStart, '/about'], [r.RoutesRecognized, '/about'],
|
||||
[r.NavigationEnd, '/about']
|
||||
]);
|
||||
}));
|
||||
|
||||
it('should navigate to "About" w/ browser location URL change', fakeAsync(() => {
|
||||
createComponent();
|
||||
location.simulateHashChange('/about');
|
||||
// location.go('/about'); // also works ... except in plunker
|
||||
// location.go('/about'); // also works ... except, perhaps, in Stackblitz
|
||||
advance();
|
||||
expectPathToBe('/about');
|
||||
expectElementOf(AboutComponent);
|
||||
|
@ -450,7 +450,7 @@ describe('TestBed Component Overrides:', () => {
|
||||
tcProvider = fixture.debugElement.injector.get(FancyService);
|
||||
tpcProvider = fixture.debugElement.children[0].injector.get(FancyService) as FakeFancyService;
|
||||
|
||||
expect(testBedProvider).not.toBe(tcProvider, 'testBed/tc not same providers');
|
||||
expect(testBedProvider).not.toBe(<any> tcProvider, 'testBed/tc not same providers');
|
||||
expect(testBedProvider).not.toBe(tpcProvider, 'testBed/tpc not same providers');
|
||||
|
||||
expect(testBedProvider instanceof FancyService).toBe(true, 'testBedProvider is FancyService');
|
||||
|
@ -235,7 +235,7 @@ export class MyIfComponent {
|
||||
providers: [FancyService]
|
||||
})
|
||||
export class TestProvidersComponent {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
constructor(public fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
|
||||
@ -245,7 +245,7 @@ export class TestProvidersComponent {
|
||||
viewProviders: [FancyService]
|
||||
})
|
||||
export class TestViewProvidersComponent {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
constructor(public fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -271,14 +271,6 @@ export class ExternalTemplateComponent implements OnInit {
|
||||
})
|
||||
export class InnerCompWithExternalTemplateComponent { }
|
||||
|
||||
@Component({
|
||||
selector: 'bad-template-comp',
|
||||
templateUrl: './non-existent.html'
|
||||
})
|
||||
export class BadTemplateUrlComponent { }
|
||||
|
||||
|
||||
|
||||
@Component({selector: 'needs-content', template: '<ng-content></ng-content>'})
|
||||
export class NeedsContentComponent {
|
||||
// children with #content local variable
|
||||
|
@ -123,7 +123,7 @@ function overrideSetup() {
|
||||
it('fixture injected service is not the component injected service',
|
||||
inject([HeroDetailService], (service: HeroDetailService) => {
|
||||
|
||||
expect(service).toEqual({}, 'service injected from fixture');
|
||||
expect(service).toEqual(<any> {}, 'service injected from fixture');
|
||||
expect(hdsSpy).toBeTruthy('service injected into component');
|
||||
}));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ describe('HeroListComponent', () => {
|
||||
it('1st hero should match 1st test hero', () => {
|
||||
const expectedHero = HEROES[0];
|
||||
const actualHero = page.heroRows[0].textContent;
|
||||
expect(actualHero).toContain(expectedHero.id, 'hero.id');
|
||||
expect(actualHero).toContain(expectedHero.id.toString(), 'hero.id');
|
||||
expect(actualHero).toContain(expectedHero.name, 'hero.name');
|
||||
});
|
||||
|
||||
@ -118,7 +118,7 @@ class Page {
|
||||
/** Hero line elements */
|
||||
heroRows: HTMLLIElement[];
|
||||
|
||||
/** Highlighted element */
|
||||
/** Highlighted DebugElement */
|
||||
highlightDe: DebugElement;
|
||||
|
||||
/** Spy on router navigate method */
|
||||
|
3
aio/content/examples/testing/src/app/model/index.ts
Normal file
3
aio/content/examples/testing/src/app/model/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './hero';
|
||||
export * from './hero.service';
|
||||
export * from './user.service';
|
@ -0,0 +1 @@
|
||||
export * from './fake-hero.service';
|
Reference in New Issue
Block a user