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 | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 19 | import {IconService, LogService} from 'gui2-fw-lib'; |
| 20 | import { |
| 21 | DeviceNodeSvgComponent, |
| 22 | HostNodeSvgComponent, LinkVisualComponent, |
| 23 | SubRegionNodeSvgComponent |
| 24 | } from './visuals'; |
| 25 | import {DraggableDirective} from './draggable/draggable.directive'; |
| 26 | import {ActivatedRoute, Params} from '@angular/router'; |
| 27 | import {of} from 'rxjs'; |
| 28 | |
| 29 | class MockActivatedRoute extends ActivatedRoute { |
| 30 | constructor(params: Params) { |
| 31 | super(); |
| 32 | this.queryParams = of(params); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | class MockIconService { |
| 37 | loadIconDef() { } |
| 38 | } |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 39 | |
| 40 | describe('ForceSvgComponent', () => { |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 41 | let ar: MockActivatedRoute; |
| 42 | let windowMock: Window; |
| 43 | let logServiceSpy: jasmine.SpyObj<LogService>; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 44 | let component: ForceSvgComponent; |
| 45 | let fixture: ComponentFixture<ForceSvgComponent>; |
| 46 | |
| 47 | beforeEach(async(() => { |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 48 | 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 Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 63 | TestBed.configureTestingModule({ |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 64 | 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 Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 76 | }) |
| 77 | .compileComponents(); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 78 | logServiceSpy = TestBed.get(LogService); |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 79 | })); |
| 80 | |
| 81 | beforeEach(() => { |
| 82 | fixture = TestBed.createComponent(ForceSvgComponent); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 83 | component = fixture.debugElement.componentInstance; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 84 | fixture.detectChanges(); |
| 85 | }); |
| 86 | |
| 87 | it('should create', () => { |
| 88 | expect(component).toBeTruthy(); |
| 89 | }); |
| 90 | }); |