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 { ActivatedRoute, Params } from '@angular/router'; |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 18 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
| 19 | import { FormsModule } from '@angular/forms'; |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 20 | import { AlarmTableComponent } from './alarmtable.component'; |
| 21 | import { AlarmDetailsComponent } from '../alarmdetails/alarmdetails.component'; |
| 22 | import { |
| 23 | FnService, |
| 24 | IconService, |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 25 | IconComponent, |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 26 | LogService, |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 27 | TableFilterPipe, LoadingComponent, |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 28 | } from 'gui2-fw-lib/public_api'; |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 29 | |
| 30 | import { of } from 'rxjs'; |
| 31 | import { } from 'jasmine'; |
| 32 | import { RouterTestingModule } from '@angular/router/testing'; |
| 33 | |
| 34 | class MockActivatedRoute extends ActivatedRoute { |
| 35 | constructor(params: Params) { |
| 36 | super(); |
| 37 | this.queryParams = of(params); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | class MockIconService { |
| 42 | loadIconDef() { } |
| 43 | } |
| 44 | |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 45 | describe('AlarmTableComponent', () => { |
| 46 | let fs: FnService; |
| 47 | let ar: MockActivatedRoute; |
| 48 | let windowMock: Window; |
| 49 | let logServiceSpy: jasmine.SpyObj<LogService>; |
| 50 | let component: AlarmTableComponent; |
| 51 | let fixture: ComponentFixture<AlarmTableComponent>; |
| 52 | |
| 53 | beforeEach(async(() => { |
| 54 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 55 | ar = new MockActivatedRoute({ 'debug': 'txrx' }); |
| 56 | |
| 57 | windowMock = <any>{ |
| 58 | location: <any>{ |
| 59 | hostname: 'foo', |
| 60 | host: 'foo', |
| 61 | port: '80', |
| 62 | protocol: 'http', |
| 63 | search: { debug: 'true' }, |
| 64 | href: 'ws://foo:123/onos/ui/websock/path', |
| 65 | absUrl: 'ws://foo:123/onos/ui/websock/path' |
| 66 | } |
| 67 | }; |
| 68 | fs = new FnService(ar, logSpy, windowMock); |
| 69 | |
| 70 | TestBed.configureTestingModule({ |
| 71 | imports: [BrowserAnimationsModule, FormsModule, RouterTestingModule], |
| 72 | declarations: [ |
| 73 | AlarmTableComponent, AlarmDetailsComponent, |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 74 | IconComponent, TableFilterPipe, LoadingComponent |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 75 | ], |
| 76 | providers: [ |
| 77 | { provide: FnService, useValue: fs }, |
| 78 | { provide: LogService, useValue: logSpy }, |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 79 | { provide: IconService, useClass: MockIconService }, |
| 80 | { provide: 'Window', useValue: windowMock }, |
| 81 | ] |
| 82 | }) |
| 83 | .compileComponents(); |
| 84 | logServiceSpy = TestBed.get(LogService); |
| 85 | })); |
| 86 | |
| 87 | beforeEach(() => { |
| 88 | fixture = TestBed.createComponent(AlarmTableComponent); |
| 89 | component = fixture.componentInstance; |
| 90 | fixture.detectChanges(); |
| 91 | }); |
| 92 | |
| 93 | it('should create', () => { |
| 94 | expect(component).toBeTruthy(); |
| 95 | }); |
| 96 | }); |