blob: 9a2ae0e3f93564bf019f4221c850f768b1a09baa [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';
17
18import { ForceSvgComponent } from './forcesvg.component';
Sean Condon71910542019-02-16 18:16:42 +000019import {FnService, LogService} from 'gui2-fw-lib';
Sean Condon0c577f62018-11-18 22:40:05 +000020import {DraggableDirective} from './draggable/draggable.directive';
21import {ActivatedRoute, Params} from '@angular/router';
22import {of} from 'rxjs';
Sean Condon71910542019-02-16 18:16:42 +000023import {MapSvgComponent} from '../mapsvg/mapsvg.component';
Sean Condonff85fbe2019-03-16 14:28:46 +000024import {DeviceNodeSvgComponent} from './visuals/devicenodesvg/devicenodesvg.component';
25import {SubRegionNodeSvgComponent} from './visuals/subregionnodesvg/subregionnodesvg.component';
26import {HostNodeSvgComponent} from './visuals/hostnodesvg/hostnodesvg.component';
27import {LinkSvgComponent} from './visuals/linksvg/linksvg.component';
Sean Condon0c577f62018-11-18 22:40:05 +000028
29class MockActivatedRoute extends ActivatedRoute {
30 constructor(params: Params) {
31 super();
32 this.queryParams = of(params);
33 }
34}
35
Sean Condonf4f54a12018-10-10 23:25:46 +010036describe('ForceSvgComponent', () => {
Sean Condon71910542019-02-16 18:16:42 +000037 let fs: FnService;
Sean Condon0c577f62018-11-18 22:40:05 +000038 let ar: MockActivatedRoute;
39 let windowMock: Window;
40 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonf4f54a12018-10-10 23:25:46 +010041 let component: ForceSvgComponent;
42 let fixture: ComponentFixture<ForceSvgComponent>;
43
44 beforeEach(async(() => {
Sean Condon0c577f62018-11-18 22:40:05 +000045 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
Sean Condon71910542019-02-16 18:16:42 +000060 fs = new FnService(ar, logSpy, windowMock);
61
Sean Condonf4f54a12018-10-10 23:25:46 +010062 TestBed.configureTestingModule({
Sean Condon0c577f62018-11-18 22:40:05 +000063 declarations: [
64 ForceSvgComponent,
65 DeviceNodeSvgComponent,
66 HostNodeSvgComponent,
67 SubRegionNodeSvgComponent,
Sean Condon50855cf2018-12-23 15:37:42 +000068 LinkSvgComponent,
Sean Condon71910542019-02-16 18:16:42 +000069 DraggableDirective,
70 MapSvgComponent
Sean Condon0c577f62018-11-18 22:40:05 +000071 ],
72 providers: [
Sean Condon71910542019-02-16 18:16:42 +000073 { provide: FnService, useValue: fs },
Sean Condon0c577f62018-11-18 22:40:05 +000074 { provide: LogService, useValue: logSpy },
Sean Condon71910542019-02-16 18:16:42 +000075 { provide: 'Window', useValue: windowMock },
Sean Condon0c577f62018-11-18 22:40:05 +000076 ]
Sean Condonf4f54a12018-10-10 23:25:46 +010077 })
78 .compileComponents();
Sean Condon0c577f62018-11-18 22:40:05 +000079 logServiceSpy = TestBed.get(LogService);
Sean Condonf4f54a12018-10-10 23:25:46 +010080 }));
81
82 beforeEach(() => {
83 fixture = TestBed.createComponent(ForceSvgComponent);
Sean Condon0c577f62018-11-18 22:40:05 +000084 component = fixture.debugElement.componentInstance;
Sean Condonf4f54a12018-10-10 23:25:46 +010085 fixture.detectChanges();
86 });
87
88 it('should create', () => {
89 expect(component).toBeTruthy();
90 });
91});