-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathoutput.component.spec.ts
43 lines (34 loc) · 1.07 KB
/
output.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
36
37
38
39
40
41
42
43
/* tslint:disable:no-unused-variable */
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { OutputComponent } from './output.component';
describe('OutputComponent', () => {
let component: OutputComponent;
let fixture: ComponentFixture<OutputComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [OutputComponent]
});
}));
beforeEach(() => {
fixture = TestBed.createComponent(OutputComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should test the emitter with a Jasmine spy', () => {
spyOn(component.greet, 'emit');
const button = fixture.nativeElement.querySelector('button');
button.click();
expect(component.greet.emit).toHaveBeenCalledWith('Hi');
});
it('should test the emitter with a simple subscribe', () => {
let greet;
component.greet.subscribe(d => {
greet = d;
});
component.doGreet();
expect(greet).toBe('Hi');
});
});