Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 17 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 18 | import { LogService } from '../../../../app/log.service'; |
| 19 | import { ConsoleLoggerService } from '../../../../app/consolelogger.service'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 20 | import { DeviceComponent } from '../../../../app/view/device/device.component'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 21 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 22 | import { DetailsPanelService } from '../../../../app/fw/layer/detailspanel.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 23 | import { FnService, WindowSize } from '../../../../app/fw/util/fn.service'; |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 24 | import { IconService } from '../../../../app/fw/svg/icon.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 25 | import { GlyphService } from '../../../../app/fw/svg/glyph.service'; |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 26 | import { KeyService } from '../../../../app/fw/util/key.service'; |
| 27 | import { LoadingService } from '../../../../app/fw/layer/loading.service'; |
| 28 | import { NavService } from '../../../../app/fw/nav/nav.service'; |
| 29 | import { MastService } from '../../../../app/fw/mast/mast.service'; |
| 30 | import { PanelService } from '../../../../app/fw/layer/panel.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 31 | import { SvgUtilService } from '../../../../app/fw/svg/svgutil.service'; |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 32 | import { TableBuilderService } from '../../../../app/fw/widget/tablebuilder.service'; |
| 33 | import { TableDetailService } from '../../../../app/fw/widget/tabledetail.service'; |
| 34 | import { WebSocketService } from '../../../../app/fw/remote/websocket.service'; |
| 35 | |
| 36 | class MockDetailsPanelService {} |
| 37 | |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 38 | class MockFnService { |
| 39 | windowSize(offH: number = 0, offW: number = 0): WindowSize { |
| 40 | return { |
| 41 | height: 123, |
| 42 | width: 456 |
| 43 | }; |
| 44 | } |
| 45 | } |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 46 | |
| 47 | class MockIconService {} |
| 48 | |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 49 | class MockGlyphService {} |
| 50 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 51 | class MockKeyService {} |
| 52 | |
| 53 | class MockLoadingService { |
| 54 | startAnim() { |
| 55 | // Do nothing |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | class MockNavService {} |
| 60 | |
| 61 | class MockMastService {} |
| 62 | |
| 63 | class MockPanelService {} |
| 64 | |
| 65 | class MockTableBuilderService {} |
| 66 | |
| 67 | class MockTableDetailService {} |
| 68 | |
| 69 | class MockWebSocketService {} |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * ONOS GUI -- Device View Module - Unit Tests |
| 73 | */ |
| 74 | describe('DeviceComponent', () => { |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 75 | let log: LogService; |
| 76 | let component: DeviceComponent; |
| 77 | let fixture: ComponentFixture<DeviceComponent>; |
| 78 | const windowMock = <any>{ location: <any> { hostname: 'localhost' } }; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 79 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 80 | beforeEach(async(() => { |
| 81 | log = new ConsoleLoggerService(); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 82 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 83 | TestBed.configureTestingModule({ |
| 84 | declarations: [ DeviceComponent ], |
| 85 | providers: [ |
| 86 | { provide: DetailsPanelService, useClass: MockDetailsPanelService }, |
| 87 | { provide: FnService, useClass: MockFnService }, |
| 88 | { provide: IconService, useClass: MockIconService }, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 89 | { provide: GlyphService, useClass: MockGlyphService }, |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 90 | { 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 Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 104 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 105 | beforeEach(() => { |
| 106 | fixture = TestBed.createComponent(DeviceComponent); |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 107 | component = fixture.componentInstance; |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 108 | fixture.detectChanges(); |
| 109 | }); |
| 110 | |
| 111 | it('should create', () => { |
| 112 | expect(component).toBeTruthy(); |
| 113 | }); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 114 | }); |