blob: 103e29fa956f42fd70aecc3c379a5473e9bc5e50 [file] [log] [blame]
Sean Condona36f65c2019-05-20 08:21:41 +01001/*
2 * Copyright ${year}-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { async, ComponentFixture, TestBed } from '@angular/core/testing';
17
18import { WelcomeComponent } from './welcome.component';
Sean Condon27f06da2019-05-25 17:02:14 +010019import {ActivatedRoute, Params} from '@angular/router';
20import { of } from 'rxjs';
21import { } from 'jasmine';
22import {
23 FnService,
24 IconService,
25 IconComponent,
26 LogService,
27 TableFilterPipe, LoadingComponent,
28} from 'gui2-fw-lib';
29import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
30import {FormsModule} from '@angular/forms';
31import {RouterTestingModule} from '@angular/router/testing';
32
33class MockActivatedRoute extends ActivatedRoute {
34 constructor(params: Params) {
35 super();
36 this.queryParams = of(params);
37 }
38}
39
40class MockIconService {
41 loadIconDef() { }
42}
Sean Condona36f65c2019-05-20 08:21:41 +010043
44describe('WelcomeComponent', () => {
Sean Condon27f06da2019-05-25 17:02:14 +010045 let fs: FnService;
46 let ar: MockActivatedRoute;
47 let windowMock: Window;
48 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condona36f65c2019-05-20 08:21:41 +010049 let component: WelcomeComponent;
50 let fixture: ComponentFixture<WelcomeComponent>;
51
52 beforeEach(async(() => {
Sean Condon27f06da2019-05-25 17:02:14 +010053 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
54 ar = new MockActivatedRoute({ 'debug': 'txrx' });
55
56 windowMock = <any>{
57 location: <any>{
58 hostname: 'foo',
59 host: 'foo',
60 port: '80',
61 protocol: 'http',
62 search: { debug: 'true' },
63 href: 'ws://foo:123/onos/ui/websock/path',
64 absUrl: 'ws://foo:123/onos/ui/websock/path'
65 }
66 };
67 fs = new FnService(ar, logSpy, windowMock);
68
Sean Condona36f65c2019-05-20 08:21:41 +010069 TestBed.configureTestingModule({
Sean Condon27f06da2019-05-25 17:02:14 +010070 imports: [BrowserAnimationsModule, FormsModule, RouterTestingModule],
71 declarations: [ WelcomeComponent ],
72 providers: [
73 { provide: FnService, useValue: fs },
74 { provide: LogService, useValue: logSpy },
75 { provide: IconService, useClass: MockIconService },
76 { provide: 'Window', useValue: windowMock },
77 ]
Sean Condona36f65c2019-05-20 08:21:41 +010078 })
79 .compileComponents();
Sean Condon27f06da2019-05-25 17:02:14 +010080 logServiceSpy = TestBed.get(LogService);
Sean Condona36f65c2019-05-20 08:21:41 +010081 }));
82
83 beforeEach(() => {
84 fixture = TestBed.createComponent(WelcomeComponent);
85 component = fixture.componentInstance;
86 fixture.detectChanges();
87 });
88
89 it('should create', () => {
90 expect(component).toBeTruthy();
91 });
92});