Sean Condon | fd6d11b | 2018-06-02 20:29:49 +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 | |
| 17 | /* |
| 18 | ONOS GUI -- Layer -- Veil Service - Unit Tests |
| 19 | */ |
| 20 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 21 | import { ActivatedRoute, Params } from '@angular/router'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 22 | |
| 23 | import { VeilComponent } from './veil.component'; |
| 24 | import { ConsoleLoggerService } from '../../../consolelogger.service'; |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame^] | 25 | import { FnService } from '../../util/fn.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 26 | import { LogService } from '../../../log.service'; |
| 27 | import { KeyService } from '../../util/key.service'; |
| 28 | import { GlyphService } from '../../svg/glyph.service'; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 29 | import { of } from 'rxjs'; |
| 30 | |
| 31 | class MockActivatedRoute extends ActivatedRoute { |
| 32 | constructor(params: Params) { |
| 33 | super(); |
| 34 | this.queryParams = of(params); |
| 35 | } |
| 36 | } |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 37 | |
| 38 | class MockKeyService {} |
| 39 | |
| 40 | class MockGlyphService {} |
| 41 | |
| 42 | describe('VeilComponent', () => { |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 43 | let fs: FnService; |
| 44 | let ar: MockActivatedRoute; |
| 45 | let windowMock: Window; |
| 46 | let logServiceSpy: jasmine.SpyObj<LogService>; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 47 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 48 | beforeEach(async(() => { |
| 49 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 50 | ar = new MockActivatedRoute({}); |
| 51 | windowMock = <any>{ |
| 52 | location: <any> { |
| 53 | hostname: 'foo' |
| 54 | } |
| 55 | }; |
| 56 | fs = new FnService(ar, logSpy, windowMock); |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 57 | |
| 58 | TestBed.configureTestingModule({ |
| 59 | declarations: [ VeilComponent ], |
| 60 | providers: [ |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 61 | { provide: FnService, useValue: fs }, |
| 62 | { provide: LogService, useValue: logSpy }, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 63 | { provide: KeyService, useClass: MockKeyService }, |
| 64 | { provide: GlyphService, useClass: MockGlyphService }, |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 65 | { provide: 'Window', useValue: windowMock }, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 66 | ] |
| 67 | }); |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 68 | logServiceSpy = TestBed.get(LogService); |
| 69 | })); |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 70 | |
| 71 | it('should create', () => { |
| 72 | const fixture = TestBed.createComponent(VeilComponent); |
| 73 | const component = fixture.componentInstance; |
| 74 | expect(component).toBeTruthy(); |
| 75 | }); |
| 76 | }); |