blob: a834e7303f2f6c22fff5ba70c39695c98c6a3c6c [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 {
21 DeviceNodeSvgComponent,
Sean Condon50855cf2018-12-23 15:37:42 +000022 HostNodeSvgComponent, LinkSvgComponent,
Sean Condon0c577f62018-11-18 22:40:05 +000023 SubRegionNodeSvgComponent
24} from './visuals';
25import {DraggableDirective} from './draggable/draggable.directive';
26import {ActivatedRoute, Params} from '@angular/router';
27import {of} from 'rxjs';
Sean Condon71910542019-02-16 18:16:42 +000028import {MapSvgComponent} from '../mapsvg/mapsvg.component';
Sean Condon0c577f62018-11-18 22:40:05 +000029
30class MockActivatedRoute extends ActivatedRoute {
31 constructor(params: Params) {
32 super();
33 this.queryParams = of(params);
34 }
35}
36
Sean Condonf4f54a12018-10-10 23:25:46 +010037describe('ForceSvgComponent', () => {
Sean Condon71910542019-02-16 18:16:42 +000038 let fs: FnService;
Sean Condon0c577f62018-11-18 22:40:05 +000039 let ar: MockActivatedRoute;
40 let windowMock: Window;
41 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonf4f54a12018-10-10 23:25:46 +010042 let component: ForceSvgComponent;
43 let fixture: ComponentFixture<ForceSvgComponent>;
44
45 beforeEach(async(() => {
Sean Condon0c577f62018-11-18 22:40:05 +000046 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
Sean Condon71910542019-02-16 18:16:42 +000061 fs = new FnService(ar, logSpy, windowMock);
62
Sean Condonf4f54a12018-10-10 23:25:46 +010063 TestBed.configureTestingModule({
Sean Condon0c577f62018-11-18 22:40:05 +000064 declarations: [
65 ForceSvgComponent,
66 DeviceNodeSvgComponent,
67 HostNodeSvgComponent,
68 SubRegionNodeSvgComponent,
Sean Condon50855cf2018-12-23 15:37:42 +000069 LinkSvgComponent,
Sean Condon71910542019-02-16 18:16:42 +000070 DraggableDirective,
71 MapSvgComponent
Sean Condon0c577f62018-11-18 22:40:05 +000072 ],
73 providers: [
Sean Condon71910542019-02-16 18:16:42 +000074 { provide: FnService, useValue: fs },
Sean Condon0c577f62018-11-18 22:40:05 +000075 { provide: LogService, useValue: logSpy },
Sean Condon71910542019-02-16 18:16:42 +000076 { provide: 'Window', useValue: windowMock },
Sean Condon0c577f62018-11-18 22:40:05 +000077 ]
Sean Condonf4f54a12018-10-10 23:25:46 +010078 })
79 .compileComponents();
Sean Condon0c577f62018-11-18 22:40:05 +000080 logServiceSpy = TestBed.get(LogService);
Sean Condonf4f54a12018-10-10 23:25:46 +010081 }));
82
83 beforeEach(() => {
84 fixture = TestBed.createComponent(ForceSvgComponent);
Sean Condon0c577f62018-11-18 22:40:05 +000085 component = fixture.debugElement.componentInstance;
Sean Condonf4f54a12018-10-10 23:25:46 +010086 fixture.detectChanges();
87 });
88
89 it('should create', () => {
90 expect(component).toBeTruthy();
91 });
92});