blob: 548377d69fb09ace9da1a8aa08b27c6aa8b6c4d2 [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 {
Sean Condon9c9b06c2019-06-06 15:41:42 +010023 Gui2FwLibModule,
Sean Condon27f06da2019-05-25 17:02:14 +010024 FnService,
25 IconService,
26 IconComponent,
27 LogService,
28 TableFilterPipe, LoadingComponent,
29} from 'gui2-fw-lib';
30import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
31import {FormsModule} from '@angular/forms';
32import {RouterTestingModule} from '@angular/router/testing';
33
34class MockActivatedRoute extends ActivatedRoute {
35 constructor(params: Params) {
36 super();
37 this.queryParams = of(params);
38 }
39}
40
41class MockIconService {
42 loadIconDef() { }
43}
Sean Condona36f65c2019-05-20 08:21:41 +010044
45describe('WelcomeComponent', () => {
Sean Condon27f06da2019-05-25 17:02:14 +010046 let fs: FnService;
47 let ar: MockActivatedRoute;
48 let windowMock: Window;
49 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condona36f65c2019-05-20 08:21:41 +010050 let component: WelcomeComponent;
51 let fixture: ComponentFixture<WelcomeComponent>;
52
53 beforeEach(async(() => {
Sean Condon27f06da2019-05-25 17:02:14 +010054 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
55 ar = new MockActivatedRoute({ 'debug': 'txrx' });
56
57 windowMock = <any>{
58 location: <any>{
59 hostname: 'foo',
60 host: 'foo',
61 port: '80',
62 protocol: 'http',
63 search: { debug: 'true' },
64 href: 'ws://foo:123/onos/ui/websock/path',
65 absUrl: 'ws://foo:123/onos/ui/websock/path'
66 }
67 };
68 fs = new FnService(ar, logSpy, windowMock);
69
Sean Condona36f65c2019-05-20 08:21:41 +010070 TestBed.configureTestingModule({
Sean Condon9c9b06c2019-06-06 15:41:42 +010071 imports: [
72 BrowserAnimationsModule,
73 FormsModule,
74 RouterTestingModule,
75 Gui2FwLibModule
76 ],
Sean Condon27f06da2019-05-25 17:02:14 +010077 declarations: [ WelcomeComponent ],
78 providers: [
79 { provide: FnService, useValue: fs },
80 { provide: LogService, useValue: logSpy },
81 { provide: IconService, useClass: MockIconService },
82 { provide: 'Window', useValue: windowMock },
83 ]
Sean Condona36f65c2019-05-20 08:21:41 +010084 })
85 .compileComponents();
Sean Condon27f06da2019-05-25 17:02:14 +010086 logServiceSpy = TestBed.get(LogService);
Sean Condona36f65c2019-05-20 08:21:41 +010087 }));
88
89 beforeEach(() => {
90 fixture = TestBed.createComponent(WelcomeComponent);
91 component = fixture.componentInstance;
92 fixture.detectChanges();
93 });
94
95 it('should create', () => {
96 expect(component).toBeTruthy();
97 });
98});