blob: 36b6e37c7f30053b26a10bb105ae1e5c87a77c71 [file] [log] [blame]
Sean Condon0c577f62018-11-18 22:40:05 +00001/*
2 * Copyright 2018-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 */
16import { ZoomableDirective } from './zoomable.directive';
17import {inject, TestBed} from '@angular/core/testing';
Sean Condon0c577f62018-11-18 22:40:05 +000018import {ElementRef} from '@angular/core';
Sean Condon0d064ec2019-02-04 21:53:53 +000019import {ActivatedRoute, Params} from '@angular/router';
20import {of} from 'rxjs';
Sean Condon14d442f2019-12-09 14:16:19 +000021import {FnService} from '../util/fn.service';
22import {LogService} from '../log.service';
23import {ConsoleLoggerService} from '../consolelogger.service';
Sean Condon0d064ec2019-02-04 21:53:53 +000024
25class MockActivatedRoute extends ActivatedRoute {
26 constructor(params: Params) {
27 super();
28 this.queryParams = of(params);
29 }
30}
Sean Condon0c577f62018-11-18 22:40:05 +000031
32describe('ZoomableDirective', () => {
Sean Condon0d064ec2019-02-04 21:53:53 +000033 let fs: FnService;
34 let ar: MockActivatedRoute;
Sean Condon0c577f62018-11-18 22:40:05 +000035 let log: LogService;
36 let mockWindow: Window;
37
38 beforeEach(() => {
39 log = new ConsoleLoggerService();
Sean Condon0d064ec2019-02-04 21:53:53 +000040 ar = new MockActivatedRoute({ 'debug': 'txrx' });
Sean Condon0c577f62018-11-18 22:40:05 +000041
42 mockWindow = <any>{
43 navigator: {
44 userAgent: 'HeadlessChrome',
45 vendor: 'Google Inc.'
Sean Condon0d064ec2019-02-04 21:53:53 +000046 },
47 location: <any>{
48 hostname: 'foo',
49 host: 'foo',
50 port: '80',
51 protocol: 'http',
52 search: { debug: 'true' },
53 href: 'ws://foo:123/onos/ui/websock/path',
54 absUrl: 'ws://foo:123/onos/ui/websock/path'
Sean Condon0c577f62018-11-18 22:40:05 +000055 }
56 };
57
Sean Condon0d064ec2019-02-04 21:53:53 +000058 fs = new FnService(ar, log, mockWindow);
59
Sean Condon0c577f62018-11-18 22:40:05 +000060 TestBed.configureTestingModule({
61 providers: [ZoomableDirective,
Sean Condon0d064ec2019-02-04 21:53:53 +000062 { provide: FnService, useValue: fs },
63 { provide: LogService, useValue: log },
64 { provide: 'Window', useValue: mockWindow },
Sean Condon0c577f62018-11-18 22:40:05 +000065 { provide: ElementRef, useValue: mockWindow }
66 ]
67 });
68 });
69
70 it('should create an instance', inject([ZoomableDirective], (directive: ZoomableDirective) => {
71
72 expect(directive).toBeTruthy();
73 }));
74});