blob: 63a51d1b4c0d819432e7cca96f836f9b7074177b [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,
Boyuan Yan6b23b382019-06-04 11:59:35 -070026 LogService,
Boyuan Yan6b23b382019-06-04 11:59:35 -070027 Gui2FwLibModule,
Sean Condon98b6ddb2019-12-24 08:07:40 +000028} from '../../../../../../web/gui2-fw-lib/public_api';
Boyuan Yan6b23b382019-06-04 11:59:35 -070029import {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}
43
44describe('RoadmDeviceComponent', () => {
45 let fs: FnService;
46 let ar: MockActivatedRoute;
47 let windowMock: Window;
48 let logServiceSpy: jasmine.SpyObj<LogService>;
49 let component: RoadmDeviceComponent;
50 let fixture: ComponentFixture<RoadmDeviceComponent>;
51
52 beforeEach(async(() => {
53 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
69 TestBed.configureTestingModule({
70 imports: [BrowserAnimationsModule, CommonModule, FormsModule, RouterTestingModule, Gui2FwLibModule],
71 declarations: [
72 RoadmDeviceComponent
73 ],
74 providers: [
75 { provide: FnService, useValue: fs },
76 { provide: LogService, useValue: logSpy },
77 { provide: IconService, useClass: MockIconService },
78 { provide: 'Window', useValue: windowMock },
79 ]
80 })
81 .compileComponents();
82 logServiceSpy = TestBed.get(LogService);
83 }));
84
85 beforeEach(() => {
86 fixture = TestBed.createComponent(RoadmDeviceComponent);
87 component = fixture.componentInstance;
88 fixture.detectChanges();
89 });
90
91 it('should create', () => {
92 expect(component).toBeTruthy();
93 });
94});