Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +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 | import { TestBed, inject } from '@angular/core/testing'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 18 | import { of } from 'rxjs'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 19 | |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 20 | import { LogService } from '../log.service'; |
| 21 | import { ConsoleLoggerService } from '../consolelogger.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 22 | import { ActivatedRoute, Params } from '@angular/router'; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 23 | import { FnService } from '../util/fn.service'; |
| 24 | import { GlyphService } from '../svg/glyph.service'; |
| 25 | import { LionService } from './lion.service'; |
| 26 | import { UrlFnService } from '../remote/urlfn.service'; |
| 27 | import { WSock } from '../remote/wsock.service'; |
| 28 | import { WebSocketService, WsOptions } from '../remote/websocket.service'; |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 29 | |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 30 | class MockActivatedRoute extends ActivatedRoute { |
| 31 | constructor(params: Params) { |
| 32 | super(); |
| 33 | this.queryParams = of(params); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | class MockWSock {} |
| 38 | |
| 39 | class MockGlyphService {} |
| 40 | |
| 41 | class MockUrlFnService {} |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * ONOS GUI -- Lion -- Localization Utilities - Unit Tests |
| 45 | */ |
| 46 | describe('LionService', () => { |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 47 | let log: LogService; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 48 | let fs: FnService; |
| 49 | let ar: MockActivatedRoute; |
| 50 | let windowMock: Window; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 51 | |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 52 | beforeEach(() => { |
| 53 | log = new ConsoleLoggerService(); |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 54 | ar = new MockActivatedRoute({'debug': 'TestService'}); |
| 55 | windowMock = <any>{ |
| 56 | location: <any> { |
| 57 | hostname: '', |
| 58 | host: '', |
| 59 | port: '', |
| 60 | protocol: '', |
| 61 | search: { debug: 'true'}, |
| 62 | href: '' |
| 63 | } |
| 64 | }; |
| 65 | fs = new FnService(ar, log, windowMock); |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 66 | |
| 67 | TestBed.configureTestingModule({ |
| 68 | providers: [LionService, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 69 | { provide: FnService, useValue: fs }, |
| 70 | { provide: GlyphService, useClass: MockGlyphService }, |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 71 | { provide: LogService, useValue: log }, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 72 | { provide: UrlFnService, useClass: MockUrlFnService }, |
| 73 | { provide: WSock, useClass: MockWSock }, |
| 74 | { provide: WebSocketService, useClass: WebSocketService }, |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 75 | { provide: 'Window', useFactory: (() => windowMock ) }, |
Sean Condon | 49e15be | 2018-05-16 16:58:29 +0100 | [diff] [blame] | 76 | ] |
| 77 | }); |
| 78 | }); |
| 79 | |
| 80 | it('should be created', inject([LionService], (service: LionService) => { |
| 81 | expect(service).toBeTruthy(); |
| 82 | })); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 83 | }); |