Sean Condon | 50855cf | 2018-12-23 15:37:42 +0000 | [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 { LinkSvgComponent } from './linksvg.component'; |
| 19 | import {LogService} from 'gui2-fw-lib'; |
| 20 | import {ActivatedRoute, Params} from '@angular/router'; |
| 21 | import {of} from 'rxjs'; |
| 22 | import {Device, Link, RegionLink, LinkType} from '../../models'; |
| 23 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; |
| 24 | |
| 25 | class MockActivatedRoute extends ActivatedRoute { |
| 26 | constructor(params: Params) { |
| 27 | super(); |
| 28 | this.queryParams = of(params); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | describe('LinkVisualComponent', () => { |
| 33 | let logServiceSpy: jasmine.SpyObj<LogService>; |
| 34 | let component: LinkSvgComponent; |
| 35 | let fixture: ComponentFixture<LinkSvgComponent>; |
| 36 | let ar: MockActivatedRoute; |
| 37 | let testLink: Link; |
| 38 | let testDeviceA: Device; |
| 39 | let testDeviceB: Device; |
| 40 | |
| 41 | beforeEach(async(() => { |
| 42 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 43 | ar = new MockActivatedRoute({ 'debug': 'txrx' }); |
| 44 | |
| 45 | testDeviceA = new Device('test:A'); |
| 46 | testDeviceA.online = true; |
| 47 | |
| 48 | testDeviceB = new Device('test:B'); |
| 49 | testDeviceB.online = true; |
| 50 | |
| 51 | testLink = new RegionLink(LinkType.UiDeviceLink, testDeviceA, testDeviceB); |
| 52 | testLink.id = 'test:A/1-test:B/1'; |
| 53 | |
| 54 | TestBed.configureTestingModule({ |
| 55 | imports: [ BrowserAnimationsModule ], |
| 56 | declarations: [ LinkSvgComponent ], |
| 57 | providers: [ |
| 58 | { provide: LogService, useValue: logSpy }, |
| 59 | { provide: ActivatedRoute, useValue: ar }, |
| 60 | ] |
| 61 | }) |
| 62 | .compileComponents(); |
| 63 | logServiceSpy = TestBed.get(LogService); |
| 64 | })); |
| 65 | |
| 66 | beforeEach(() => { |
| 67 | fixture = TestBed.createComponent(LinkSvgComponent); |
| 68 | component = fixture.componentInstance; |
| 69 | component.link = testLink; |
| 70 | fixture.detectChanges(); |
| 71 | }); |
| 72 | |
| 73 | it('should create', () => { |
| 74 | expect(component).toBeTruthy(); |
| 75 | }); |
| 76 | }); |