blob: 5dfb73c78395b80bef701ef2b182a64127b3f0b0 [file] [log] [blame]
Sean Condonb2c483c2019-01-16 20:28:55 +00001/*
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 */
16import { async, ComponentFixture, TestBed } from '@angular/core/testing';
17
18import { QuickhelpComponent } from './quickhelp.component';
19import {LogService} from '../../log.service';
20import {ConsoleLoggerService} from '../../consolelogger.service';
21import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
22import {FnService} from '../../util/fn.service';
23import {LionService} from '../../util/lion.service';
24import {KeysService} from '../../util/keys.service';
25
26class MockFnService {}
27
28class MockKeysService {
Sean Condonbed2e032019-04-17 22:22:49 +010029 keyHandler: {
30 viewKeys: any[],
31 globalKeys: any[]
32 };
Sean Condonb2c483c2019-01-16 20:28:55 +000033
Sean Condonbed2e032019-04-17 22:22:49 +010034 mockViewKeys: Object[];
35 constructor() {
36 this.mockViewKeys = [];
37 this.keyHandler = {
38 viewKeys: this.mockViewKeys,
39 globalKeys: this.mockViewKeys
40 };
41 }
Sean Condonb2c483c2019-01-16 20:28:55 +000042}
43
44/**
45 * ONOS GUI -- Layer -- Quickhelp Component - Unit Tests
46 */
47describe('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});