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 { |
| 29 | |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * ONOS GUI -- Layer -- Quickhelp Component - Unit Tests |
| 34 | */ |
| 35 | describe('QuickhelpComponent', () => { |
| 36 | let log: LogService; |
| 37 | let component: QuickhelpComponent; |
| 38 | let fixture: ComponentFixture<QuickhelpComponent>; |
| 39 | const bundleObj = { |
| 40 | 'core.fw.QuickHelp': { |
| 41 | test: 'test1', |
| 42 | tt_help: 'Help!' |
| 43 | } |
| 44 | }; |
| 45 | const mockLion = (key) => { |
| 46 | return bundleObj[key] || '%' + key + '%'; |
| 47 | }; |
| 48 | |
| 49 | beforeEach(async(() => { |
| 50 | log = new ConsoleLoggerService(); |
| 51 | TestBed.configureTestingModule({ |
| 52 | imports: [ BrowserAnimationsModule ], |
| 53 | declarations: [ QuickhelpComponent ], |
| 54 | providers: [ |
| 55 | { provide: LogService, useValue: log }, |
| 56 | { provide: FnService, useClass: MockFnService }, |
| 57 | { provide: LionService, useFactory: (() => { |
| 58 | return { |
| 59 | bundle: ((bundleId) => mockLion), |
| 60 | ubercache: new Array(), |
| 61 | loadCbs: new Map<string, () => void>([]) |
| 62 | }; |
| 63 | }) |
| 64 | }, |
| 65 | { provide: KeysService, useClass: MockKeysService } |
| 66 | ] |
| 67 | }) |
| 68 | .compileComponents(); |
| 69 | })); |
| 70 | |
| 71 | beforeEach(() => { |
| 72 | fixture = TestBed.createComponent(QuickhelpComponent); |
| 73 | component = fixture.componentInstance; |
| 74 | fixture.detectChanges(); |
| 75 | }); |
| 76 | |
| 77 | it('should create', () => { |
| 78 | expect(component).toBeTruthy(); |
| 79 | }); |
| 80 | }); |