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'; |
Matteo Scandolo | 8b9f164 | 2016-12-05 17:08:26 -0800 | [diff] [blame^] | 4 | import {LogoutComponent} from './components/logout/logout.component'; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 5 | import {TestBed, async} from '@angular/core/testing'; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 6 | import {StyleConfig} from './config/style.config'; |
| 7 | import { Http, BaseRequestOptions } from '@angular/http'; |
| 8 | import { MockBackend } from '@angular/http/testing'; |
Matteo Scandolo | 8b9f164 | 2016-12-05 17:08:26 -0800 | [diff] [blame^] | 9 | import {CookieService} from 'angular2-cookie/services/cookies.service'; |
| 10 | import {Router} from '@angular/router'; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 11 | |
| 12 | describe('hello component', () => { |
| 13 | beforeEach(async(() => { |
| 14 | TestBed.configureTestingModule({ |
| 15 | declarations: [ |
Matteo Scandolo | 8b9f164 | 2016-12-05 17:08:26 -0800 | [diff] [blame^] | 16 | HelloComponent, |
| 17 | LogoutComponent |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 18 | ], |
| 19 | providers: [ |
| 20 | { |
| 21 | provide: Http, |
| 22 | useFactory: (mockBackend, options) => { |
| 23 | return new Http(mockBackend, options); |
| 24 | }, |
| 25 | deps: [MockBackend, BaseRequestOptions] |
| 26 | }, |
| 27 | MockBackend, |
Matteo Scandolo | 8b9f164 | 2016-12-05 17:08:26 -0800 | [diff] [blame^] | 28 | BaseRequestOptions, |
| 29 | CookieService, |
| 30 | { |
| 31 | provide: Router, |
| 32 | useClass: class { navigate = jasmine.createSpy('navigate'); } |
| 33 | } |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 34 | ] |
| 35 | }); |
| 36 | TestBed.compileComponents(); |
| 37 | })); |
| 38 | |
| 39 | it('should render hello world', () => { |
| 40 | const fixture = TestBed.createComponent(HelloComponent); |
| 41 | fixture.detectChanges(); |
| 42 | const hello = fixture.nativeElement; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 43 | expect(hello.querySelector('h1').textContent).toBe(`Hello ${StyleConfig.projectName}!`); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 44 | }); |
| 45 | }); |