blob: 90a629e15c72840b2a7a73c8e182b7e249ee7be8 [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';
Sean Condon50855cf2018-12-23 15:37:42 +000025import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
Sean Condonf4f54a12018-10-10 23:25:46 +010026
27class MockActivatedRoute extends ActivatedRoute {
28 constructor(params: Params) {
29 super();
30 this.queryParams = of(params);
31 }
32}
33
34/**
35 * ONOS GUI -- Topology View Topology Panel-- Unit Tests
36 */
37describe('ToolbarComponent', () => {
38 let fs: FnService;
39 let ar: MockActivatedRoute;
40 let windowMock: Window;
41 let logServiceSpy: jasmine.SpyObj<LogService>;
42 let component: ToolbarComponent;
43 let fixture: ComponentFixture<ToolbarComponent>;
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 TestBed.configureTestingModule({
Sean Condon50855cf2018-12-23 15:37:42 +000062 imports: [ BrowserAnimationsModule ],
Sean Condonf4f54a12018-10-10 23:25:46 +010063 declarations: [ ToolbarComponent ],
64 providers: [
65 { provide: FnService, useValue: fs },
66 { provide: LogService, useValue: logSpy },
67 { provide: 'Window', useValue: windowMock },
68 ]
69 })
70 .compileComponents();
71 logServiceSpy = TestBed.get(LogService);
72 }));
73
74 beforeEach(() => {
75 fixture = TestBed.createComponent(ToolbarComponent);
76 component = fixture.componentInstance;
77 fixture.detectChanges();
78 });
79
80 it('should create', () => {
81 expect(component).toBeTruthy();
82 });
83});