Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 1 | /* |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 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'; |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 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 | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 26 | import { LogService } from '../../log.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 27 | import { GlyphService } from '../../svg/glyph.service'; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 28 | import { of } from 'rxjs'; |
| 29 | |
| 30 | class MockActivatedRoute extends ActivatedRoute { |
| 31 | constructor(params: Params) { |
| 32 | super(); |
| 33 | this.queryParams = of(params); |
| 34 | } |
| 35 | } |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 36 | |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 37 | class MockGlyphService {} |
| 38 | |
| 39 | describe('VeilComponent', () => { |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 40 | let fs: FnService; |
| 41 | let ar: MockActivatedRoute; |
| 42 | let windowMock: Window; |
| 43 | let logServiceSpy: jasmine.SpyObj<LogService>; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 44 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 45 | beforeEach(async(() => { |
| 46 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
| 47 | ar = new MockActivatedRoute({}); |
| 48 | windowMock = <any>{ |
| 49 | location: <any> { |
| 50 | hostname: 'foo' |
| 51 | } |
| 52 | }; |
| 53 | fs = new FnService(ar, logSpy, windowMock); |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 54 | |
| 55 | TestBed.configureTestingModule({ |
| 56 | declarations: [ VeilComponent ], |
| 57 | providers: [ |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 58 | { provide: FnService, useValue: fs }, |
| 59 | { provide: LogService, useValue: logSpy }, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 60 | { provide: GlyphService, useClass: MockGlyphService }, |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 61 | { provide: 'Window', useValue: windowMock }, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 62 | ] |
| 63 | }); |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 64 | logServiceSpy = TestBed.get(LogService); |
| 65 | })); |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 66 | |
| 67 | it('should create', () => { |
| 68 | const fixture = TestBed.createComponent(VeilComponent); |
| 69 | const component = fixture.componentInstance; |
| 70 | expect(component).toBeTruthy(); |
| 71 | }); |
| 72 | }); |