blob: 32ed2efd7897c78d36d3adc741a5e11514991c92 [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';
19import {LogService} from 'gui2-fw-lib';
20import {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
33describe('DeviceNodeSvgComponent', () => {
34 let logServiceSpy: jasmine.SpyObj<LogService>;
35 let component: DeviceNodeSvgComponent;
36 let fixture: ComponentFixture<DeviceNodeSvgComponent>;
37 let ar: MockActivatedRoute;
38 let testDevice: Device;
39
40
41 beforeEach(async(() => {
42 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
43 ar = new MockActivatedRoute({ 'debug': 'txrx' });
44 testDevice = new Device('test:1');
45 testDevice.online = true;
46
47 TestBed.configureTestingModule({
Sean Condon50855cf2018-12-23 15:37:42 +000048 imports: [ BrowserAnimationsModule ],
Sean Condon0c577f62018-11-18 22:40:05 +000049 declarations: [ DeviceNodeSvgComponent ],
50 providers: [
51 { provide: LogService, useValue: logSpy },
52 { provide: ActivatedRoute, useValue: ar },
53 { provide: ChangeDetectorRef, useClass: ChangeDetectorRef }
54 ]
55 })
56 .compileComponents();
57 logServiceSpy = TestBed.get(LogService);
58 }));
59
60 beforeEach(() => {
61 fixture = TestBed.createComponent(DeviceNodeSvgComponent);
62 component = fixture.componentInstance;
63 component.device = testDevice;
64 fixture.detectChanges();
65 });
66
67 it('should create', () => {
68 expect(component).toBeTruthy();
69 });
70});