blob: 23d75c5dad82cf48d7ff4cd870ccbc3d070af816 [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 Condon0d064ec2019-02-04 21:53:53 +000018import {LogService, ConsoleLoggerService, FnService} from 'gui2-fw-lib';
Sean Condon0c577f62018-11-18 22:40:05 +000019import {ElementRef} from '@angular/core';
Sean Condon0d064ec2019-02-04 21:53:53 +000020import {ActivatedRoute, Params} from '@angular/router';
21import {of} from 'rxjs';
22
23class MockActivatedRoute extends ActivatedRoute {
24 constructor(params: Params) {
25 super();
26 this.queryParams = of(params);
27 }
28}
Sean Condon0c577f62018-11-18 22:40:05 +000029
30describe('ZoomableDirective', () => {
Sean Condon0d064ec2019-02-04 21:53:53 +000031 let fs: FnService;
32 let ar: MockActivatedRoute;
Sean Condon0c577f62018-11-18 22:40:05 +000033 let log: LogService;
34 let mockWindow: Window;
35
36 beforeEach(() => {
37 log = new ConsoleLoggerService();
Sean Condon0d064ec2019-02-04 21:53:53 +000038 ar = new MockActivatedRoute({ 'debug': 'txrx' });
Sean Condon0c577f62018-11-18 22:40:05 +000039
40 mockWindow = <any>{
41 navigator: {
42 userAgent: 'HeadlessChrome',
43 vendor: 'Google Inc.'
Sean Condon0d064ec2019-02-04 21:53:53 +000044 },
45 location: <any>{
46 hostname: 'foo',
47 host: 'foo',
48 port: '80',
49 protocol: 'http',
50 search: { debug: 'true' },
51 href: 'ws://foo:123/onos/ui/websock/path',
52 absUrl: 'ws://foo:123/onos/ui/websock/path'
Sean Condon0c577f62018-11-18 22:40:05 +000053 }
54 };
55
Sean Condon0d064ec2019-02-04 21:53:53 +000056 fs = new FnService(ar, log, mockWindow);
57
Sean Condon0c577f62018-11-18 22:40:05 +000058 TestBed.configureTestingModule({
59 providers: [ZoomableDirective,
Sean Condon0d064ec2019-02-04 21:53:53 +000060 { provide: FnService, useValue: fs },
61 { provide: LogService, useValue: log },
62 { provide: 'Window', useValue: mockWindow },
Sean Condon0c577f62018-11-18 22:40:05 +000063 { provide: ElementRef, useValue: mockWindow }
64 ]
65 });
66 });
67
68 it('should create an instance', inject([ZoomableDirective], (directive: ZoomableDirective) => {
69
70 expect(directive).toBeTruthy();
71 }));
72});