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 | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 11 | import {XosHttp} from './services/rest/xoshttp.service'; |
| 12 | import {InstanceStore} from './services/stores/instance.store'; |
| 13 | import {GlobalEvent} from './services/websockets/websocket.global'; |
| 14 | import {AuthService} from './services/rest/auth.service'; |
| 15 | import {InstanceService} from './services/rest/instance.service'; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 16 | |
| 17 | describe('hello component', () => { |
| 18 | beforeEach(async(() => { |
| 19 | TestBed.configureTestingModule({ |
| 20 | declarations: [ |
Matteo Scandolo | 8b9f164 | 2016-12-05 17:08:26 -0800 | [diff] [blame] | 21 | HelloComponent, |
| 22 | LogoutComponent |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 23 | ], |
| 24 | providers: [ |
| 25 | { |
| 26 | provide: Http, |
| 27 | useFactory: (mockBackend, options) => { |
| 28 | return new Http(mockBackend, options); |
| 29 | }, |
| 30 | deps: [MockBackend, BaseRequestOptions] |
| 31 | }, |
| 32 | MockBackend, |
Matteo Scandolo | 8b9f164 | 2016-12-05 17:08:26 -0800 | [diff] [blame] | 33 | BaseRequestOptions, |
| 34 | CookieService, |
| 35 | { |
| 36 | provide: Router, |
| 37 | useClass: class { navigate = jasmine.createSpy('navigate'); } |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 38 | }, |
| 39 | XosHttp, |
| 40 | InstanceStore, |
| 41 | GlobalEvent, |
| 42 | AuthService, |
| 43 | InstanceService |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 44 | ] |
| 45 | }); |
| 46 | TestBed.compileComponents(); |
| 47 | })); |
| 48 | |
| 49 | it('should render hello world', () => { |
| 50 | const fixture = TestBed.createComponent(HelloComponent); |
| 51 | fixture.detectChanges(); |
| 52 | const hello = fixture.nativeElement; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 53 | expect(hello.querySelector('h1').textContent).toBe(`Hello ${StyleConfig.projectName}!`); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 54 | }); |
| 55 | }); |