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