Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 1 | /// <reference path="../../typings/index.d.ts"/> |
| 2 | |
| 3 | import {HelloComponent} from './hello'; |
| 4 | import {TestBed, async} from '@angular/core/testing'; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame^] | 5 | import {StyleConfig} from './config/style.config'; |
| 6 | import { Http, BaseRequestOptions } from '@angular/http'; |
| 7 | import { MockBackend } from '@angular/http/testing'; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 8 | |
| 9 | describe('hello component', () => { |
| 10 | beforeEach(async(() => { |
| 11 | TestBed.configureTestingModule({ |
| 12 | declarations: [ |
| 13 | HelloComponent |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame^] | 14 | ], |
| 15 | providers: [ |
| 16 | { |
| 17 | provide: Http, |
| 18 | useFactory: (mockBackend, options) => { |
| 19 | return new Http(mockBackend, options); |
| 20 | }, |
| 21 | deps: [MockBackend, BaseRequestOptions] |
| 22 | }, |
| 23 | MockBackend, |
| 24 | BaseRequestOptions |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 25 | ] |
| 26 | }); |
| 27 | TestBed.compileComponents(); |
| 28 | })); |
| 29 | |
| 30 | it('should render hello world', () => { |
| 31 | const fixture = TestBed.createComponent(HelloComponent); |
| 32 | fixture.detectChanges(); |
| 33 | const hello = fixture.nativeElement; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame^] | 34 | expect(hello.querySelector('h1').textContent).toBe(`Hello ${StyleConfig.projectName}!`); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 35 | }); |
| 36 | }); |