blob: ccad204f03fec26deb0d567b8eadd1779e3b3112 [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';
18import { DebugElement } from '@angular/core';
19import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
20import { FormsModule } from '@angular/forms';
21import { By } from '@angular/platform-browser';
22import { AlarmTableComponent } from './alarmtable.component';
23import { AlarmDetailsComponent } from '../alarmdetails/alarmdetails.component';
24import {
25 FnService,
26 IconService,
27 GlyphService,
28 IconComponent,
29 LoadingService,
30 LogService,
31 NavService,
32 MastService,
33 TableFilterPipe,
34 ThemeService,
35 WebSocketService
36} from 'gui2-fw-lib';
37
38import { of } from 'rxjs';
39import { } from 'jasmine';
40import { RouterTestingModule } from '@angular/router/testing';
41
42class MockActivatedRoute extends ActivatedRoute {
43 constructor(params: Params) {
44 super();
45 this.queryParams = of(params);
46 }
47}
48
49class MockIconService {
50 loadIconDef() { }
51}
52
53class MockLoadingService {
54 startAnim() { }
55 stop() { }
56 waiting() { }
57}
58
59describe('AlarmTableComponent', () => {
60 let fs: FnService;
61 let ar: MockActivatedRoute;
62 let windowMock: Window;
63 let logServiceSpy: jasmine.SpyObj<LogService>;
64 let component: AlarmTableComponent;
65 let fixture: ComponentFixture<AlarmTableComponent>;
66
67 beforeEach(async(() => {
68 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
69 ar = new MockActivatedRoute({ 'debug': 'txrx' });
70
71 windowMock = <any>{
72 location: <any>{
73 hostname: 'foo',
74 host: 'foo',
75 port: '80',
76 protocol: 'http',
77 search: { debug: 'true' },
78 href: 'ws://foo:123/onos/ui/websock/path',
79 absUrl: 'ws://foo:123/onos/ui/websock/path'
80 }
81 };
82 fs = new FnService(ar, logSpy, windowMock);
83
84 TestBed.configureTestingModule({
85 imports: [BrowserAnimationsModule, FormsModule, RouterTestingModule],
86 declarations: [
87 AlarmTableComponent, AlarmDetailsComponent,
88 IconComponent, TableFilterPipe
89 ],
90 providers: [
91 { provide: FnService, useValue: fs },
92 { provide: LogService, useValue: logSpy },
93 { provide: LoadingService, useClass: MockLoadingService },
94 { provide: IconService, useClass: MockIconService },
95 { provide: 'Window', useValue: windowMock },
96 ]
97 })
98 .compileComponents();
99 logServiceSpy = TestBed.get(LogService);
100 }));
101
102 beforeEach(() => {
103 fixture = TestBed.createComponent(AlarmTableComponent);
104 component = fixture.componentInstance;
105 fixture.detectChanges();
106 });
107
108 it('should create', () => {
109 expect(component).toBeTruthy();
110 });
111});