blob: ffbe6672f8630219f31c5d5bcfe697dc5223b1ce [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 Condon0c577f62018-11-18 22:40:05 +000019import {IconService, LogService} from 'gui2-fw-lib';
20import {
21 DeviceNodeSvgComponent,
22 HostNodeSvgComponent, LinkVisualComponent,
23 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
36class MockIconService {
37 loadIconDef() { }
38}
Sean Condonf4f54a12018-10-10 23:25:46 +010039
40describe('ForceSvgComponent', () => {
Sean Condon0c577f62018-11-18 22:40:05 +000041 let ar: MockActivatedRoute;
42 let windowMock: Window;
43 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonf4f54a12018-10-10 23:25:46 +010044 let component: ForceSvgComponent;
45 let fixture: ComponentFixture<ForceSvgComponent>;
46
47 beforeEach(async(() => {
Sean Condon0c577f62018-11-18 22:40:05 +000048 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
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,
69 LinkVisualComponent,
70 DraggableDirective
71 ],
72 providers: [
73 { provide: LogService, useValue: logSpy },
74 { provide: IconService, useClass: MockIconService },
75 ]
Sean Condonf4f54a12018-10-10 23:25:46 +010076 })
77 .compileComponents();
Sean Condon0c577f62018-11-18 22:40:05 +000078 logServiceSpy = TestBed.get(LogService);
Sean Condonf4f54a12018-10-10 23:25:46 +010079 }));
80
81 beforeEach(() => {
82 fixture = TestBed.createComponent(ForceSvgComponent);
Sean Condon0c577f62018-11-18 22:40:05 +000083 component = fixture.debugElement.componentInstance;
Sean Condonf4f54a12018-10-10 23:25:46 +010084 fixture.detectChanges();
85 });
86
87 it('should create', () => {
88 expect(component).toBeTruthy();
89 });
90});