blob: 004617e43013d6e61511995ae91ea5e679cc4a8f [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 { AlarmDetailsComponent } from './alarmdetails.component';
18import { ActivatedRoute, Params } from '@angular/router';
19import { of } from 'rxjs/index';
20import {
21 FnService,
22 IconService,
23 LogService,
24 WebSocketService,
25 IconComponent
Sean Condon98b6ddb2019-12-24 08:07:40 +000026} from '../../../../../web/gui2-fw-lib/public_api';
Sean Condon87b78502018-09-17 20:53:24 +010027
28import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
29import { DebugElement } from '@angular/core';
30import { By } from '@angular/platform-browser';
31import { } from 'jasmine';
32
33class MockActivatedRoute extends ActivatedRoute {
34 constructor(params: Params) {
35 super();
36 this.queryParams = of(params);
37 }
38}
39
40class MockIconService {
41 classes = 'active-close';
42 loadIconDef() { }
43}
44
45class MockWebSocketService {
46 createWebSocket() { }
47 isConnected() { return false; }
48 unbindHandlers() { }
49 bindHandlers() { }
50}
51
52describe('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});