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 { of } from 'rxjs'; |
| 19 | import { InstanceComponent } from './instance.component'; |
| 20 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
| 21 | |
| 22 | import { |
| 23 | FnService, |
| 24 | LogService |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 25 | } from 'gui2-fw-lib/public_api'; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 26 | |
| 27 | class MockActivatedRoute extends ActivatedRoute { |
| 28 | constructor(params: Params) { |
| 29 | super(); |
| 30 | this.queryParams = of(params); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * ONOS GUI -- Topology View Instance Panel-- Unit Tests |
| 36 | */ |
| 37 | describe('InstanceComponent', () => { |
| 38 | let fs: FnService; |
| 39 | let ar: MockActivatedRoute; |
| 40 | let windowMock: Window; |
| 41 | let logServiceSpy: jasmine.SpyObj<LogService>; |
| 42 | let component: InstanceComponent; |
| 43 | let fixture: ComponentFixture<InstanceComponent>; |
| 44 | |
| 45 | beforeEach(async(() => { |
| 46 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 47 | ar = new MockActivatedRoute({ 'debug': 'txrx' }); |
| 48 | |
| 49 | windowMock = <any>{ |
| 50 | location: <any>{ |
| 51 | hostname: 'foo', |
| 52 | host: 'foo', |
| 53 | port: '80', |
| 54 | protocol: 'http', |
| 55 | search: { debug: 'true' }, |
| 56 | href: 'ws://foo:123/onos/ui/websock/path', |
| 57 | absUrl: 'ws://foo:123/onos/ui/websock/path' |
| 58 | } |
| 59 | }; |
| 60 | fs = new FnService(ar, logSpy, windowMock); |
| 61 | |
| 62 | TestBed.configureTestingModule({ |
| 63 | imports: [ BrowserAnimationsModule ], |
| 64 | declarations: [ InstanceComponent ], |
| 65 | providers: [ |
| 66 | { provide: FnService, useValue: fs }, |
| 67 | { provide: LogService, useValue: logSpy }, |
| 68 | { provide: 'Window', useValue: windowMock }, |
| 69 | ] |
| 70 | }) |
| 71 | .compileComponents(); |
| 72 | logServiceSpy = TestBed.get(LogService); |
| 73 | })); |
| 74 | |
| 75 | beforeEach(() => { |
| 76 | fixture = TestBed.createComponent(InstanceComponent); |
| 77 | component = fixture.componentInstance; |
| 78 | fixture.detectChanges(); |
| 79 | }); |
| 80 | |
| 81 | it('should create', () => { |
| 82 | expect(component).toBeTruthy(); |
| 83 | }); |
| 84 | }); |