-
Notifications
You must be signed in to change notification settings - Fork 1
/
home.component.spec.ts
83 lines (73 loc) · 1.8 KB
/
home.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { NO_ERRORS_SCHEMA } from '@angular/core';
import {
inject,
async,
TestBed,
ComponentFixture
} from '@angular/core/testing';
import { Component } from '@angular/core';
import {
BaseRequestOptions,
ConnectionBackend,
Http
} from '@angular/http';
import { MockBackend } from '@angular/http/testing';
/**
* Load the implementations that should be tested.
*/
import { AppState } from '../app.service';
import { HomeComponent } from './home.component';
import { Title } from './title';
describe(`Home`, () => {
let comp: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;
/**
* async beforeEach.
*/
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HomeComponent],
schemas: [NO_ERRORS_SCHEMA],
providers: [
BaseRequestOptions,
MockBackend,
{
provide: Http,
useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
return new Http(backend, defaultOptions);
},
deps: [MockBackend, BaseRequestOptions]
},
AppState,
Title,
]
})
/**
* Compile template and css.
*/
.compileComponents();
}));
/**
* Synchronous beforeEach.
*/
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
comp = fixture.componentInstance;
/**
* Trigger initial data binding.
*/
fixture.detectChanges();
});
it('should have default data', () => {
expect(comp.localState).toEqual({ value: '' });
});
it('should have a title', () => {
expect(!!comp.title).toEqual(true);
});
it('should log ngOnInit', () => {
spyOn(console, 'log');
expect(console.log).not.toHaveBeenCalled();
comp.ngOnInit();
expect(console.log).toHaveBeenCalled();
});
});