Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 17 | |
| 18 | import { ForceSvgComponent } from './forcesvg.component'; |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 19 | import {FnService, LogService} from 'gui2-fw-lib'; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 20 | import {DraggableDirective} from './draggable/draggable.directive'; |
| 21 | import {ActivatedRoute, Params} from '@angular/router'; |
| 22 | import {of} from 'rxjs'; |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 23 | import {MapSvgComponent} from '../mapsvg/mapsvg.component'; |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 24 | import {DeviceNodeSvgComponent} from './visuals/devicenodesvg/devicenodesvg.component'; |
| 25 | import {SubRegionNodeSvgComponent} from './visuals/subregionnodesvg/subregionnodesvg.component'; |
| 26 | import {HostNodeSvgComponent} from './visuals/hostnodesvg/hostnodesvg.component'; |
| 27 | import {LinkSvgComponent} from './visuals/linksvg/linksvg.component'; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 28 | |
| 29 | class MockActivatedRoute extends ActivatedRoute { |
| 30 | constructor(params: Params) { |
| 31 | super(); |
| 32 | this.queryParams = of(params); |
| 33 | } |
| 34 | } |
| 35 | |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 36 | describe('ForceSvgComponent', () => { |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 37 | let fs: FnService; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 38 | let ar: MockActivatedRoute; |
| 39 | let windowMock: Window; |
| 40 | let logServiceSpy: jasmine.SpyObj<LogService>; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 41 | let component: ForceSvgComponent; |
| 42 | let fixture: ComponentFixture<ForceSvgComponent>; |
| 43 | |
| 44 | beforeEach(async(() => { |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 45 | 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 Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 60 | fs = new FnService(ar, logSpy, windowMock); |
| 61 | |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 62 | TestBed.configureTestingModule({ |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 63 | declarations: [ |
| 64 | ForceSvgComponent, |
| 65 | DeviceNodeSvgComponent, |
| 66 | HostNodeSvgComponent, |
| 67 | SubRegionNodeSvgComponent, |
Sean Condon | 50855cf | 2018-12-23 15:37:42 +0000 | [diff] [blame] | 68 | LinkSvgComponent, |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 69 | DraggableDirective, |
| 70 | MapSvgComponent |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 71 | ], |
| 72 | providers: [ |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 73 | { provide: FnService, useValue: fs }, |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 74 | { provide: LogService, useValue: logSpy }, |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 75 | { provide: 'Window', useValue: windowMock }, |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 76 | ] |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 77 | }) |
| 78 | .compileComponents(); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 79 | logServiceSpy = TestBed.get(LogService); |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 80 | })); |
| 81 | |
| 82 | beforeEach(() => { |
| 83 | fixture = TestBed.createComponent(ForceSvgComponent); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 84 | component = fixture.debugElement.componentInstance; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 85 | fixture.detectChanges(); |
| 86 | }); |
| 87 | |
| 88 | it('should create', () => { |
| 89 | expect(component).toBeTruthy(); |
| 90 | }); |
| 91 | }); |