blob: b0c252c8eb6986ac4cfc0d998fd463667d5f2ee7 [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
Sean Condonf4f54a12018-10-10 23:25:46 +01002 * Copyright 2018-present Open Networking Foundation
Sean Condon83fc39f2018-04-19 18:56:13 +01003 *
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 */
17import { TestBed, inject } from '@angular/core/testing';
Sean Condonfd6d11b2018-06-02 20:29:49 +010018import { of } from 'rxjs';
Sean Condon83fc39f2018-04-19 18:56:13 +010019
Sean Condonf4f54a12018-10-10 23:25:46 +010020import { LogService } from '../log.service';
21import { ConsoleLoggerService } from '../consolelogger.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010022import { ActivatedRoute, Params } from '@angular/router';
Sean Condonf4f54a12018-10-10 23:25:46 +010023import { FnService } from '../util/fn.service';
24import { GlyphService } from '../svg/glyph.service';
25import { LionService } from './lion.service';
26import { UrlFnService } from '../remote/urlfn.service';
27import { WSock } from '../remote/wsock.service';
28import { WebSocketService, WsOptions } from '../remote/websocket.service';
Sean Condon49e15be2018-05-16 16:58:29 +010029
Sean Condonfd6d11b2018-06-02 20:29:49 +010030class MockActivatedRoute extends ActivatedRoute {
31 constructor(params: Params) {
32 super();
33 this.queryParams = of(params);
34 }
35}
36
37class MockWSock {}
38
39class MockGlyphService {}
40
41class MockUrlFnService {}
Sean Condon83fc39f2018-04-19 18:56:13 +010042
43/**
44 * ONOS GUI -- Lion -- Localization Utilities - Unit Tests
45 */
46describe('LionService', () => {
Sean Condon49e15be2018-05-16 16:58:29 +010047 let log: LogService;
Sean Condonfd6d11b2018-06-02 20:29:49 +010048 let fs: FnService;
49 let ar: MockActivatedRoute;
50 let windowMock: Window;
Sean Condon83fc39f2018-04-19 18:56:13 +010051
Sean Condon49e15be2018-05-16 16:58:29 +010052 beforeEach(() => {
53 log = new ConsoleLoggerService();
Sean Condonfd6d11b2018-06-02 20:29:49 +010054 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 Condon49e15be2018-05-16 16:58:29 +010066
67 TestBed.configureTestingModule({
68 providers: [LionService,
Sean Condonfd6d11b2018-06-02 20:29:49 +010069 { provide: FnService, useValue: fs },
70 { provide: GlyphService, useClass: MockGlyphService },
Sean Condon49e15be2018-05-16 16:58:29 +010071 { provide: LogService, useValue: log },
Sean Condonfd6d11b2018-06-02 20:29:49 +010072 { provide: UrlFnService, useClass: MockUrlFnService },
73 { provide: WSock, useClass: MockWSock },
74 { provide: WebSocketService, useClass: WebSocketService },
Sean Condona00bf382018-06-23 07:54:01 +010075 { provide: 'Window', useFactory: (() => windowMock ) },
Sean Condon49e15be2018-05-16 16:58:29 +010076 ]
77 });
78 });
79
80 it('should be created', inject([LionService], (service: LionService) => {
81 expect(service).toBeTruthy();
82 }));
Sean Condon83fc39f2018-04-19 18:56:13 +010083});