blob: 5d95f04511f8621324ac1955181b2ff714bfc22f [file] [log] [blame]
Sean Condon87b78502018-09-17 20:53:24 +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';
Sean Condon87b78502018-09-17 20:53:24 +010018import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
19import { FormsModule } from '@angular/forms';
Sean Condon87b78502018-09-17 20:53:24 +010020import { AlarmTableComponent } from './alarmtable.component';
21import { AlarmDetailsComponent } from '../alarmdetails/alarmdetails.component';
22import {
23 FnService,
24 IconService,
Sean Condon87b78502018-09-17 20:53:24 +010025 IconComponent,
Sean Condon87b78502018-09-17 20:53:24 +010026 LogService,
Sean Condon95fb5742019-04-02 12:16:55 +010027 TableFilterPipe, LoadingComponent,
Sean Condona3ad7792020-01-04 19:26:34 +000028} from 'gui2-fw-lib/public_api';
Sean Condon87b78502018-09-17 20:53:24 +010029
30import { of } from 'rxjs';
31import { } from 'jasmine';
32import { RouterTestingModule } from '@angular/router/testing';
33
34class MockActivatedRoute extends ActivatedRoute {
35 constructor(params: Params) {
36 super();
37 this.queryParams = of(params);
38 }
39}
40
41class MockIconService {
42 loadIconDef() { }
43}
44
Sean Condon87b78502018-09-17 20:53:24 +010045describe('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 Condon95fb5742019-04-02 12:16:55 +010074 IconComponent, TableFilterPipe, LoadingComponent
Sean Condon87b78502018-09-17 20:53:24 +010075 ],
76 providers: [
77 { provide: FnService, useValue: fs },
78 { provide: LogService, useValue: logSpy },
Sean Condon87b78502018-09-17 20:53:24 +010079 { 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});