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