Sean Condon | 87b7850 | 2018-09-17 20:53:24 +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 { AlarmDetailsComponent } from './alarmdetails.component'; |
| 18 | import { ActivatedRoute, Params } from '@angular/router'; |
| 19 | import { of } from 'rxjs/index'; |
| 20 | import { |
| 21 | FnService, |
| 22 | IconService, |
| 23 | LogService, |
| 24 | WebSocketService, |
| 25 | IconComponent |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 26 | } from '../../../../../web/gui2-fw-lib/public_api'; |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 27 | |
| 28 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
| 29 | import { DebugElement } from '@angular/core'; |
| 30 | import { By } from '@angular/platform-browser'; |
| 31 | import { } from 'jasmine'; |
| 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 | describe('AlarmDetailsComponent', () => { |
| 53 | let fs: FnService; |
| 54 | let ar: MockActivatedRoute; |
| 55 | let windowMock: Window; |
| 56 | let logServiceSpy: jasmine.SpyObj<LogService>; |
| 57 | let component: AlarmDetailsComponent; |
| 58 | let fixture: ComponentFixture<AlarmDetailsComponent>; |
| 59 | |
| 60 | beforeEach(async(() => { |
| 61 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 62 | ar = new MockActivatedRoute({ 'debug': 'panel' }); |
| 63 | windowMock = <any>{ |
| 64 | location: <any>{ |
| 65 | hostname: 'foo', |
| 66 | host: 'foo', |
| 67 | port: '80', |
| 68 | protocol: 'http', |
| 69 | search: { debug: 'true' }, |
| 70 | href: 'ws://foo:123/onos/ui/websock/path', |
| 71 | absUrl: 'ws://foo:123/onos/ui/websock/path' |
| 72 | } |
| 73 | }; |
| 74 | fs = new FnService(ar, logSpy, windowMock); |
| 75 | |
| 76 | TestBed.configureTestingModule({ |
| 77 | imports: [BrowserAnimationsModule], |
| 78 | declarations: [ AlarmDetailsComponent, IconComponent ], |
| 79 | providers: [ |
| 80 | { provide: FnService, useValue: fs }, |
| 81 | { provide: IconService, useClass: MockIconService }, |
| 82 | { provide: LogService, useValue: logSpy }, |
| 83 | { provide: WebSocketService, useClass: MockWebSocketService }, |
| 84 | { provide: 'Window', useValue: windowMock }, |
| 85 | ] |
| 86 | }) |
| 87 | .compileComponents(); |
| 88 | logServiceSpy = TestBed.get(LogService); |
| 89 | })); |
| 90 | |
| 91 | beforeEach(() => { |
| 92 | fixture = TestBed.createComponent(AlarmDetailsComponent); |
| 93 | component = fixture.componentInstance; |
| 94 | fixture.detectChanges(); |
| 95 | }); |
| 96 | |
| 97 | it('should create', () => { |
| 98 | expect(component).toBeTruthy(); |
| 99 | }); |
| 100 | }); |