Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* tslint:disable:no-unused-variable */
import { async, fakeAsync, tick, TestBed } from '@angular/core/testing';

import { TestBed, async } from '@angular/core/testing';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [AppModule]
});
TestBed.compileComponents();
});
Expand All @@ -19,17 +18,21 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
}));

it('should have a step components array of length 3', async(() => {
it('should have a step components array of length 3', fakeAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.stepComponents).toEqual(jasmine.any([]));
app.ngOnInit();
tick();

expect(app.stepComponents).toEqual(jasmine.any(Array));
expect(app.stepComponents.length).toEqual(3);
}));

it('should contain a step-container compoent', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();

const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('app-steps-container').length).toBe(1);
expect(compiled.querySelectorAll('app-steps-container').length).toBe(1);
}));
});
18 changes: 14 additions & 4 deletions src/app/steps-container/steps-container.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { async, fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';

import { AppModule } from '../app.module';
import { AppComponent } from '../app.component';

import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';

Expand All @@ -11,16 +15,22 @@ describe('StepsContainerComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ StepsContainerComponent ]
imports: [AppModule]
})
.compileComponents();
}));

beforeEach(() => {
beforeEach(fakeAsync(() => {
const appFixture = TestBed.createComponent(AppComponent);
const app = appFixture.debugElement.componentInstance;
app.ngOnInit();
tick();

fixture = TestBed.createComponent(StepsContainerComponent);
component = fixture.componentInstance;
component.steps = app.stepComponents;
fixture.detectChanges();
});
}));

it('should create', () => {
expect(component).toBeTruthy();
Expand Down