Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-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 { QuickhelpComponent } from './quickhelp.component'; |
| 19 | import {LogService} from '../../log.service'; |
| 20 | import {ConsoleLoggerService} from '../../consolelogger.service'; |
| 21 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; |
| 22 | import {FnService} from '../../util/fn.service'; |
| 23 | import {LionService} from '../../util/lion.service'; |
| 24 | import {KeysService} from '../../util/keys.service'; |
| 25 | |
| 26 | class MockFnService {} |
| 27 | |
| 28 | class MockKeysService { |
Sean Condon | bed2e03 | 2019-04-17 22:22:49 +0100 | [diff] [blame] | 29 | keyHandler: { |
| 30 | viewKeys: any[], |
| 31 | globalKeys: any[] |
| 32 | }; |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 33 | |
Sean Condon | bed2e03 | 2019-04-17 22:22:49 +0100 | [diff] [blame] | 34 | mockViewKeys: Object[]; |
| 35 | constructor() { |
| 36 | this.mockViewKeys = []; |
| 37 | this.keyHandler = { |
| 38 | viewKeys: this.mockViewKeys, |
| 39 | globalKeys: this.mockViewKeys |
| 40 | }; |
| 41 | } |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /** |
| 45 | * ONOS GUI -- Layer -- Quickhelp Component - Unit Tests |
| 46 | */ |
| 47 | describe('QuickhelpComponent', () => { |
| 48 | let log: LogService; |
| 49 | let component: QuickhelpComponent; |
| 50 | let fixture: ComponentFixture<QuickhelpComponent>; |
| 51 | const bundleObj = { |
| 52 | 'core.fw.QuickHelp': { |
| 53 | test: 'test1', |
| 54 | tt_help: 'Help!' |
| 55 | } |
| 56 | }; |
| 57 | const mockLion = (key) => { |
| 58 | return bundleObj[key] || '%' + key + '%'; |
| 59 | }; |
| 60 | |
| 61 | beforeEach(async(() => { |
| 62 | log = new ConsoleLoggerService(); |
| 63 | TestBed.configureTestingModule({ |
| 64 | imports: [ BrowserAnimationsModule ], |
| 65 | declarations: [ QuickhelpComponent ], |
| 66 | providers: [ |
| 67 | { provide: LogService, useValue: log }, |
| 68 | { provide: FnService, useClass: MockFnService }, |
| 69 | { provide: LionService, useFactory: (() => { |
| 70 | return { |
| 71 | bundle: ((bundleId) => mockLion), |
| 72 | ubercache: new Array(), |
| 73 | loadCbs: new Map<string, () => void>([]) |
| 74 | }; |
| 75 | }) |
| 76 | }, |
| 77 | { provide: KeysService, useClass: MockKeysService } |
| 78 | ] |
| 79 | }) |
| 80 | .compileComponents(); |
| 81 | })); |
| 82 | |
| 83 | beforeEach(() => { |
| 84 | fixture = TestBed.createComponent(QuickhelpComponent); |
| 85 | component = fixture.componentInstance; |
| 86 | fixture.detectChanges(); |
| 87 | }); |
| 88 | |
| 89 | it('should create', () => { |
| 90 | expect(component).toBeTruthy(); |
| 91 | }); |
| 92 | }); |