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