blob: b490605569ad865ed57d4b94469a5a32b201057b [file] [log] [blame]
Sean Condon0c577f62018-11-18 22:40:05 +00001/*
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 { DeviceNodeSvgComponent } from './devicenodesvg.component';
Sean Condon59d31372019-02-02 20:07:00 +000019import {IconService, LogService} from 'gui2-fw-lib';
Sean Condon0c577f62018-11-18 22:40:05 +000020import {ActivatedRoute, Params} from '@angular/router';
21import {of} from 'rxjs';
22import {ChangeDetectorRef} from '@angular/core';
23import {Device} from '../../models';
Sean Condon50855cf2018-12-23 15:37:42 +000024import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
Sean Condon0c577f62018-11-18 22:40:05 +000025
26class MockActivatedRoute extends ActivatedRoute {
27 constructor(params: Params) {
28 super();
29 this.queryParams = of(params);
30 }
31}
32
Sean Condon59d31372019-02-02 20:07:00 +000033class MockIconService {
34 loadIconDef() { }
35}
36
Sean Condon0c577f62018-11-18 22:40:05 +000037describe('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 Condon50855cf2018-12-23 15:37:42 +000052 imports: [ BrowserAnimationsModule ],
Sean Condon0c577f62018-11-18 22:40:05 +000053 declarations: [ DeviceNodeSvgComponent ],
54 providers: [
55 { provide: LogService, useValue: logSpy },
56 { provide: ActivatedRoute, useValue: ar },
Sean Condon59d31372019-02-02 20:07:00 +000057 { provide: ChangeDetectorRef, useClass: ChangeDetectorRef },
58 { provide: IconService, useClass: MockIconService }
Sean Condon0c577f62018-11-18 22:40:05 +000059 ]
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});