blob: e9735f04f18d54b7e800bd9ec8ca4f9793128c22 [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +01001/*
2 * Copyright 2018-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';
17import { ActivatedRoute, Params } from '@angular/router';
18import { NoDeviceConnectedSvgComponent } from './nodeviceconnectedsvg.component';
19import { DebugElement } from '@angular/core';
20import { By } from '@angular/platform-browser';
21import {
22 FnService,
23 IconService,
24 LionService,
25 LogService,
26 UrlFnService,
27 TableFilterPipe,
28 IconComponent,
Sean Condon91481822019-01-01 13:56:14 +000029 WebSocketService, SvgUtilService, PrefsService
Sean Condon3b3fdab2020-04-14 09:25:00 +010030} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Sean Condonf4f54a12018-10-10 23:25:46 +010031import { of } from 'rxjs';
32
33class MockActivatedRoute extends ActivatedRoute {
34 constructor(params: Params) {
35 super();
36 this.queryParams = of(params);
37 }
38}
39
Sean Condonf4f54a12018-10-10 23:25:46 +010040class MockWebSocketService {
41 createWebSocket() { }
42 isConnected() { return false; }
43 unbindHandlers() { }
44 bindHandlers() { }
45}
46
Sean Condon91481822019-01-01 13:56:14 +000047class MockSvgUtilService {
48 translate() {}
49 scale() {}
50}
51
52class MockPrefsService {
53}
54
55
Sean Condonf4f54a12018-10-10 23:25:46 +010056/**
57 * ONOS GUI -- Topology NoDevicesConnected -- Unit Tests
58 */
59describe('NoDeviceConnectedSvgComponent', () => {
60 let fs: FnService;
61 let ar: MockActivatedRoute;
62 let windowMock: Window;
63 let logServiceSpy: jasmine.SpyObj<LogService>;
64 let component: NoDeviceConnectedSvgComponent;
65 let fixture: ComponentFixture<NoDeviceConnectedSvgComponent>;
66
67
68 beforeEach(async(() => {
69 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
70 ar = new MockActivatedRoute({'debug': 'panel'});
71
72 windowMock = <any>{
Sean Condonff85fbe2019-03-16 14:28:46 +000073 innerWidth: 800,
74 innerHeight: 600,
Sean Condonf4f54a12018-10-10 23:25:46 +010075 };
76 fs = new FnService(ar, logSpy, windowMock);
77
Sean Condon64060ff2019-05-30 15:48:11 +010078 const bundleObj = {
79 'core.view.Topo': {
80 test: 'test1'
81 }
82 };
83 const mockLion = (key) => {
84 return bundleObj[key] || '%' + key + '%';
85 };
86
Sean Condonf4f54a12018-10-10 23:25:46 +010087 TestBed.configureTestingModule({
88 declarations: [ NoDeviceConnectedSvgComponent ],
89 providers: [
90 { provide: FnService, useValue: fs },
Sean Condonf4f54a12018-10-10 23:25:46 +010091 { provide: LogService, useValue: logSpy },
Sean Condon91481822019-01-01 13:56:14 +000092 { provide: SvgUtilService, useClass: MockSvgUtilService },
Sean Condonf4f54a12018-10-10 23:25:46 +010093 { provide: WebSocketService, useClass: MockWebSocketService },
Sean Condon91481822019-01-01 13:56:14 +000094 { provide: PrefsService, useClass: MockPrefsService },
Sean Condon64060ff2019-05-30 15:48:11 +010095 {
96 provide: LionService, useFactory: (() => {
97 return {
98 bundle: ((bundleId) => mockLion),
99 ubercache: new Array(),
100 loadCbs: new Map<string, () => void>([])
101 };
102 })
103 },
Sean Condonf4f54a12018-10-10 23:25:46 +0100104 { provide: 'Window', useValue: windowMock },
105 ]
106 }).compileComponents();
107 logServiceSpy = TestBed.get(LogService);
108 }));
109
110 beforeEach(() => {
111 fixture = TestBed.createComponent(NoDeviceConnectedSvgComponent);
112 component = fixture.componentInstance;
113 fixture.detectChanges();
114 });
115
116 it('should create', () => {
117 expect(component).toBeTruthy();
118 });
119});