blob: 0c0c2694e943ba2df1b28c8cb15d74418a05606f [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +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 { BrowserAnimationsModule } from '@angular/platform-browser/animations';
19import { of } from 'rxjs';
20import { DetailsComponent } from './details.component';
21
22import {
23 FnService,
24 LogService
25} from 'gui2-fw-lib';
26
27class MockActivatedRoute extends ActivatedRoute {
28 constructor(params: Params) {
29 super();
30 this.queryParams = of(params);
31 }
32}
33
34/**
35 * ONOS GUI -- Topology View Details Panel-- Unit Tests
36 */
37describe('DetailsComponent', () => {
38 let fs: FnService;
39 let ar: MockActivatedRoute;
40 let windowMock: Window;
41 let logServiceSpy: jasmine.SpyObj<LogService>;
42 let component: DetailsComponent;
43 let fixture: ComponentFixture<DetailsComponent>;
44
45 beforeEach(async(() => {
46 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
47 ar = new MockActivatedRoute({ 'debug': 'txrx' });
48
49 windowMock = <any>{
50 location: <any>{
51 hostname: 'foo',
52 host: 'foo',
53 port: '80',
54 protocol: 'http',
55 search: { debug: 'true' },
56 href: 'ws://foo:123/onos/ui/websock/path',
57 absUrl: 'ws://foo:123/onos/ui/websock/path'
58 }
59 };
60 fs = new FnService(ar, logSpy, windowMock);
61
62 TestBed.configureTestingModule({
63 imports: [ BrowserAnimationsModule ],
64 declarations: [ DetailsComponent ],
65 providers: [
66 { provide: FnService, useValue: fs },
67 { provide: LogService, useValue: logSpy },
68 { provide: 'Window', useValue: windowMock },
69 ]
70 })
71 .compileComponents();
72 logServiceSpy = TestBed.get(LogService);
73 }));
74
75 beforeEach(() => {
76 fixture = TestBed.createComponent(DetailsComponent);
77 component = fixture.componentInstance;
78 fixture.detectChanges();
79 });
80
81 it('should create', () => {
82 expect(component).toBeTruthy();
83 });
84});