blob: 13892afd41e9028a40b39b6b1dea0b914ab50e29 [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 */
16import { TestBed, inject } from '@angular/core/testing';
17
Sean Condonf4f54a12018-10-10 23:25:46 +010018import { LogService } from '../log.service';
19import { ConsoleLoggerService } from '../consolelogger.service';
20import { PrefsService } from '../util/prefs.service';
21import { FnService } from '../util/fn.service';
22import { WebSocketService } from '../remote/websocket.service';
Sean Condon49e15be2018-05-16 16:58:29 +010023
24class MockFnService {}
25
Sean Condonf4f54a12018-10-10 23:25:46 +010026class MockWebSocketService {
27 createWebSocket() {}
28 isConnected() { return false; }
29 unbindHandlers() {}
30 bindHandlers() {}
31}
Sean Condon83fc39f2018-04-19 18:56:13 +010032
33/**
Sean Condon49e15be2018-05-16 16:58:29 +010034 * ONOS GUI -- Util -- User Preference Service - Unit Tests
Sean Condon83fc39f2018-04-19 18:56:13 +010035 */
36describe('PrefsService', () => {
Sean Condon49e15be2018-05-16 16:58:29 +010037 let log: LogService;
Sean Condonb2c483c2019-01-16 20:28:55 +000038 let windowMock: Window;
39
40 windowMock = <any>{
41 location: <any> {
42 hostname: 'foo',
43 host: 'foo',
44 port: '80',
45 protocol: 'http',
46 search: { debug: 'true'},
47 href: 'ws://foo:123/onos/ui/websock/path',
48 absUrl: 'ws://foo:123/onos/ui/websock/path'
49 }
50 };
Sean Condon83fc39f2018-04-19 18:56:13 +010051
Sean Condon49e15be2018-05-16 16:58:29 +010052 beforeEach(() => {
53 log = new ConsoleLoggerService();
54
55 TestBed.configureTestingModule({
56 providers: [PrefsService,
57 { provide: LogService, useValue: log },
58 { provide: FnService, useClass: MockFnService },
Sean Condonb2c483c2019-01-16 20:28:55 +000059 { provide: 'Window', useFactory: (() => windowMock ) },
Sean Condon49e15be2018-05-16 16:58:29 +010060 { provide: WebSocketService, useClass: MockWebSocketService },
61 ]
62 });
63 });
64
65 it('should be created', inject([PrefsService], (service: PrefsService) => {
66 expect(service).toBeTruthy();
67 }));
Sean Condon83fc39f2018-04-19 18:56:13 +010068});