Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 17 | import { ActivatedRoute, Params } from '@angular/router'; |
| 18 | import { NoDeviceConnectedSvgComponent } from './nodeviceconnectedsvg.component'; |
| 19 | import { DebugElement } from '@angular/core'; |
| 20 | import { By } from '@angular/platform-browser'; |
| 21 | import { |
| 22 | FnService, |
| 23 | IconService, |
| 24 | LionService, |
| 25 | LogService, |
| 26 | UrlFnService, |
| 27 | TableFilterPipe, |
| 28 | IconComponent, |
| 29 | WebSocketService |
| 30 | } from 'gui2-fw-lib'; |
| 31 | import { of } from 'rxjs'; |
| 32 | |
| 33 | class MockActivatedRoute extends ActivatedRoute { |
| 34 | constructor(params: Params) { |
| 35 | super(); |
| 36 | this.queryParams = of(params); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | class MockIconService { |
| 41 | classes = 'active-close'; |
| 42 | loadIconDef() { } |
| 43 | } |
| 44 | |
| 45 | class MockWebSocketService { |
| 46 | createWebSocket() { } |
| 47 | isConnected() { return false; } |
| 48 | unbindHandlers() { } |
| 49 | bindHandlers() { } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * ONOS GUI -- Topology NoDevicesConnected -- Unit Tests |
| 54 | */ |
| 55 | describe('NoDeviceConnectedSvgComponent', () => { |
| 56 | let fs: FnService; |
| 57 | let ar: MockActivatedRoute; |
| 58 | let windowMock: Window; |
| 59 | let logServiceSpy: jasmine.SpyObj<LogService>; |
| 60 | let component: NoDeviceConnectedSvgComponent; |
| 61 | let fixture: ComponentFixture<NoDeviceConnectedSvgComponent>; |
| 62 | |
| 63 | |
| 64 | beforeEach(async(() => { |
| 65 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 66 | ar = new MockActivatedRoute({'debug': 'panel'}); |
| 67 | |
| 68 | windowMock = <any>{ |
| 69 | }; |
| 70 | fs = new FnService(ar, logSpy, windowMock); |
| 71 | |
| 72 | TestBed.configureTestingModule({ |
| 73 | declarations: [ NoDeviceConnectedSvgComponent ], |
| 74 | providers: [ |
| 75 | { provide: FnService, useValue: fs }, |
| 76 | { provide: IconService, useClass: MockIconService }, |
| 77 | { provide: LogService, useValue: logSpy }, |
| 78 | { provide: WebSocketService, useClass: MockWebSocketService }, |
| 79 | { provide: 'Window', useValue: windowMock }, |
| 80 | ] |
| 81 | }).compileComponents(); |
| 82 | logServiceSpy = TestBed.get(LogService); |
| 83 | })); |
| 84 | |
| 85 | beforeEach(() => { |
| 86 | fixture = TestBed.createComponent(NoDeviceConnectedSvgComponent); |
| 87 | component = fixture.componentInstance; |
| 88 | fixture.detectChanges(); |
| 89 | }); |
| 90 | |
| 91 | it('should create', () => { |
| 92 | expect(component).toBeTruthy(); |
| 93 | }); |
| 94 | }); |