-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathcomponent.spec.ts
35 lines (30 loc) · 1.12 KB
/
component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Component, Input } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { CoreModule } from '../../core/module';
import { AnimalType } from '../model';
import { AnimalListComponent } from './component';
@Component({ selector: 'zoo-animal', template: '' })
class MockAnimalComponent {
@Input() key: string;
@Input() animalType: AnimalType;
}
xdescribe('AnimalListComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AnimalListComponent, MockAnimalComponent],
imports: [CoreModule],
}).compileComponents();
}));
it("should have as title 'Welcome to the Zoo'", async(() => {
const fixture = TestBed.createComponent(AnimalListComponent);
const animalList = fixture.debugElement.componentInstance;
animalList.animalsName = 'Wallabies';
animalList.animalType = 'WALLABIES';
fixture.detectChanges();
const titleElement = fixture.debugElement.query(By.css('h2'));
expect(titleElement.nativeElement.textContent).toContain(
'We have Wallabies',
);
}));
});