blob: 30e8e792fc4ee73412368c7fe6fe6eb8c16671e5 [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001/// <reference path="../../typings/index.d.ts"/>
2
3import {HelloComponent} from './hello';
Matteo Scandolo8b9f1642016-12-05 17:08:26 -08004import {LogoutComponent} from './components/logout/logout.component';
Matteo Scandolod819c922016-12-02 14:06:14 -08005import {TestBed, async} from '@angular/core/testing';
Matteo Scandolo43ffb672016-12-02 14:49:58 -08006import {StyleConfig} from './config/style.config';
7import { Http, BaseRequestOptions } from '@angular/http';
8import { MockBackend } from '@angular/http/testing';
Matteo Scandolo8b9f1642016-12-05 17:08:26 -08009import {CookieService} from 'angular2-cookie/services/cookies.service';
10import {Router} from '@angular/router';
Matteo Scandolod819c922016-12-02 14:06:14 -080011
12describe('hello component', () => {
13 beforeEach(async(() => {
14 TestBed.configureTestingModule({
15 declarations: [
Matteo Scandolo8b9f1642016-12-05 17:08:26 -080016 HelloComponent,
17 LogoutComponent
Matteo Scandolo43ffb672016-12-02 14:49:58 -080018 ],
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 Scandolo8b9f1642016-12-05 17:08:26 -080028 BaseRequestOptions,
29 CookieService,
30 {
31 provide: Router,
32 useClass: class { navigate = jasmine.createSpy('navigate'); }
33 }
Matteo Scandolod819c922016-12-02 14:06:14 -080034 ]
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 Scandolo43ffb672016-12-02 14:49:58 -080043 expect(hello.querySelector('h1').textContent).toBe(`Hello ${StyleConfig.projectName}!`);
Matteo Scandolod819c922016-12-02 14:06:14 -080044 });
45});