blob: 960d241bb9b1e63bd35393a8dcfd6121fec5e900 [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
2 * Copyright 2015-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
Sean Condon49e15be2018-05-16 16:58:29 +010018import { LogService } from '../../../../app/log.service';
19import { ConsoleLoggerService } from '../../../../app/consolelogger.service';
Sean Condon83fc39f2018-04-19 18:56:13 +010020import { DeviceComponent } from '../../../../app/view/device/device.component';
Sean Condonfd6d11b2018-06-02 20:29:49 +010021
Sean Condon49e15be2018-05-16 16:58:29 +010022import { DetailsPanelService } from '../../../../app/fw/layer/detailspanel.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010023import { FnService, WindowSize } from '../../../../app/fw/util/fn.service';
Sean Condon49e15be2018-05-16 16:58:29 +010024import { IconService } from '../../../../app/fw/svg/icon.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010025import { GlyphService } from '../../../../app/fw/svg/glyph.service';
Sean Condon49e15be2018-05-16 16:58:29 +010026import { KeyService } from '../../../../app/fw/util/key.service';
27import { LoadingService } from '../../../../app/fw/layer/loading.service';
28import { NavService } from '../../../../app/fw/nav/nav.service';
29import { MastService } from '../../../../app/fw/mast/mast.service';
30import { PanelService } from '../../../../app/fw/layer/panel.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010031import { SvgUtilService } from '../../../../app/fw/svg/svgutil.service';
Sean Condon49e15be2018-05-16 16:58:29 +010032import { TableBuilderService } from '../../../../app/fw/widget/tablebuilder.service';
33import { TableDetailService } from '../../../../app/fw/widget/tabledetail.service';
34import { WebSocketService } from '../../../../app/fw/remote/websocket.service';
35
36class MockDetailsPanelService {}
37
Sean Condonfd6d11b2018-06-02 20:29:49 +010038class MockFnService {
39 windowSize(offH: number = 0, offW: number = 0): WindowSize {
40 return {
41 height: 123,
42 width: 456
43 };
44 }
45}
Sean Condon49e15be2018-05-16 16:58:29 +010046
47class MockIconService {}
48
Sean Condonfd6d11b2018-06-02 20:29:49 +010049class MockGlyphService {}
50
Sean Condon49e15be2018-05-16 16:58:29 +010051class MockKeyService {}
52
53class MockLoadingService {
54 startAnim() {
55 // Do nothing
56 }
57}
58
59class MockNavService {}
60
61class MockMastService {}
62
63class MockPanelService {}
64
65class MockTableBuilderService {}
66
67class MockTableDetailService {}
68
69class MockWebSocketService {}
Sean Condon83fc39f2018-04-19 18:56:13 +010070
71/**
72 * ONOS GUI -- Device View Module - Unit Tests
73 */
74describe('DeviceComponent', () => {
Sean Condon49e15be2018-05-16 16:58:29 +010075 let log: LogService;
76 let component: DeviceComponent;
77 let fixture: ComponentFixture<DeviceComponent>;
78 const windowMock = <any>{ location: <any> { hostname: 'localhost' } };
Sean Condon83fc39f2018-04-19 18:56:13 +010079
Sean Condon49e15be2018-05-16 16:58:29 +010080 beforeEach(async(() => {
81 log = new ConsoleLoggerService();
Sean Condon83fc39f2018-04-19 18:56:13 +010082
Sean Condon49e15be2018-05-16 16:58:29 +010083 TestBed.configureTestingModule({
84 declarations: [ DeviceComponent ],
85 providers: [
86 { provide: DetailsPanelService, useClass: MockDetailsPanelService },
87 { provide: FnService, useClass: MockFnService },
88 { provide: IconService, useClass: MockIconService },
Sean Condonfd6d11b2018-06-02 20:29:49 +010089 { provide: GlyphService, useClass: MockGlyphService },
Sean Condon49e15be2018-05-16 16:58:29 +010090 { provide: KeyService, useClass: MockKeyService },
91 { provide: LoadingService, useClass: MockLoadingService },
92 { provide: MastService, useClass: MockMastService },
93 { provide: NavService, useClass: MockNavService },
94 { provide: LogService, useValue: log },
95 { provide: PanelService, useClass: MockPanelService },
96 { provide: TableBuilderService, useClass: MockTableBuilderService },
97 { provide: TableDetailService, useClass: MockTableDetailService },
98 { provide: WebSocketService, useClass: MockWebSocketService },
99 { provide: Window, useValue: windowMock },
100 ]
101 })
102 .compileComponents();
103 }));
Sean Condon83fc39f2018-04-19 18:56:13 +0100104
Sean Condon49e15be2018-05-16 16:58:29 +0100105 beforeEach(() => {
106 fixture = TestBed.createComponent(DeviceComponent);
Sean Condonfd6d11b2018-06-02 20:29:49 +0100107 component = fixture.componentInstance;
Sean Condon49e15be2018-05-16 16:58:29 +0100108 fixture.detectChanges();
109 });
110
111 it('should create', () => {
112 expect(component).toBeTruthy();
113 });
Sean Condon83fc39f2018-04-19 18:56:13 +0100114});