blob: 815fc0bcf7eb69dd59a440783a84f5d17075695b [file] [log] [blame]
Boyuan Yan6b23b382019-06-04 11:59:35 -07001/*
2 * Copyright 2019-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 { RoadmDeviceComponent } from './roadm.component';
19import {ActivatedRoute, Params} from '@angular/router';
20import {CommonModule} from '@angular/common';
21import { of } from 'rxjs';
22import { } from 'jasmine';
23import {
24 FnService,
25 IconService,
26 IconComponent,
27 LogService,
28 TableFilterPipe,
29 LoadingComponent,
30 Gui2FwLibModule,
31} from 'gui2-fw-lib';
32import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
33import {FormsModule} from '@angular/forms';
34import {RouterTestingModule} from '@angular/router/testing';
35
36class MockActivatedRoute extends ActivatedRoute {
37 constructor(params: Params) {
38 super();
39 this.queryParams = of(params);
40 }
41}
42
43class MockIconService {
44 loadIconDef() { }
45}
46
47describe('RoadmDeviceComponent', () => {
48 let fs: FnService;
49 let ar: MockActivatedRoute;
50 let windowMock: Window;
51 let logServiceSpy: jasmine.SpyObj<LogService>;
52 let component: RoadmDeviceComponent;
53 let fixture: ComponentFixture<RoadmDeviceComponent>;
54
55 beforeEach(async(() => {
56 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
57 ar = new MockActivatedRoute({ 'debug': 'txrx' });
58
59 windowMock = <any>{
60 location: <any>{
61 hostname: 'foo',
62 host: 'foo',
63 port: '80',
64 protocol: 'http',
65 search: { debug: 'true' },
66 href: 'ws://foo:123/onos/ui/websock/path',
67 absUrl: 'ws://foo:123/onos/ui/websock/path'
68 }
69 };
70 fs = new FnService(ar, logSpy, windowMock);
71
72 TestBed.configureTestingModule({
73 imports: [BrowserAnimationsModule, CommonModule, FormsModule, RouterTestingModule, Gui2FwLibModule],
74 declarations: [
75 RoadmDeviceComponent
76 ],
77 providers: [
78 { provide: FnService, useValue: fs },
79 { provide: LogService, useValue: logSpy },
80 { provide: IconService, useClass: MockIconService },
81 { provide: 'Window', useValue: windowMock },
82 ]
83 })
84 .compileComponents();
85 logServiceSpy = TestBed.get(LogService);
86 }));
87
88 beforeEach(() => {
89 fixture = TestBed.createComponent(RoadmDeviceComponent);
90 component = fixture.componentInstance;
91 fixture.detectChanges();
92 });
93
94 it('should create', () => {
95 expect(component).toBeTruthy();
96 });
97});