blob: 7a30d753adbbbda274090b7990871e60ff10d26f [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 Condon91481822019-01-01 13:56:14 +000019import {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';
28
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 Condon0c577f62018-11-18 22:40:05 +000037 let ar: MockActivatedRoute;
38 let windowMock: Window;
39 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonf4f54a12018-10-10 23:25:46 +010040 let component: ForceSvgComponent;
41 let fixture: ComponentFixture<ForceSvgComponent>;
42
43 beforeEach(async(() => {
Sean Condon0c577f62018-11-18 22:40:05 +000044 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
45 ar = new MockActivatedRoute({ 'debug': 'txrx' });
46
47 windowMock = <any>{
48 location: <any>{
49 hostname: 'foo',
50 host: 'foo',
51 port: '80',
52 protocol: 'http',
53 search: { debug: 'true' },
54 href: 'ws://foo:123/onos/ui/websock/path',
55 absUrl: 'ws://foo:123/onos/ui/websock/path'
56 }
57 };
58
Sean Condonf4f54a12018-10-10 23:25:46 +010059 TestBed.configureTestingModule({
Sean Condon0c577f62018-11-18 22:40:05 +000060 declarations: [
61 ForceSvgComponent,
62 DeviceNodeSvgComponent,
63 HostNodeSvgComponent,
64 SubRegionNodeSvgComponent,
Sean Condon50855cf2018-12-23 15:37:42 +000065 LinkSvgComponent,
Sean Condon0c577f62018-11-18 22:40:05 +000066 DraggableDirective
67 ],
68 providers: [
69 { provide: LogService, useValue: logSpy },
Sean Condon0c577f62018-11-18 22:40:05 +000070 ]
Sean Condonf4f54a12018-10-10 23:25:46 +010071 })
72 .compileComponents();
Sean Condon0c577f62018-11-18 22:40:05 +000073 logServiceSpy = TestBed.get(LogService);
Sean Condonf4f54a12018-10-10 23:25:46 +010074 }));
75
76 beforeEach(() => {
77 fixture = TestBed.createComponent(ForceSvgComponent);
Sean Condon0c577f62018-11-18 22:40:05 +000078 component = fixture.debugElement.componentInstance;
Sean Condonf4f54a12018-10-10 23:25:46 +010079 fixture.detectChanges();
80 });
81
82 it('should create', () => {
83 expect(component).toBeTruthy();
84 });
85});