Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { ZoomableDirective } from './zoomable.directive'; |
| 17 | import {inject, TestBed} from '@angular/core/testing'; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 18 | import {ElementRef} from '@angular/core'; |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 19 | import {ActivatedRoute, Params} from '@angular/router'; |
| 20 | import {of} from 'rxjs'; |
Sean Condon | 14d442f | 2019-12-09 14:16:19 +0000 | [diff] [blame] | 21 | import {FnService} from '../util/fn.service'; |
| 22 | import {LogService} from '../log.service'; |
| 23 | import {ConsoleLoggerService} from '../consolelogger.service'; |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 24 | |
| 25 | class MockActivatedRoute extends ActivatedRoute { |
| 26 | constructor(params: Params) { |
| 27 | super(); |
| 28 | this.queryParams = of(params); |
| 29 | } |
| 30 | } |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 31 | |
| 32 | describe('ZoomableDirective', () => { |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 33 | let fs: FnService; |
| 34 | let ar: MockActivatedRoute; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 35 | let log: LogService; |
| 36 | let mockWindow: Window; |
| 37 | |
| 38 | beforeEach(() => { |
| 39 | log = new ConsoleLoggerService(); |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 40 | ar = new MockActivatedRoute({ 'debug': 'txrx' }); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 41 | |
| 42 | mockWindow = <any>{ |
| 43 | navigator: { |
| 44 | userAgent: 'HeadlessChrome', |
| 45 | vendor: 'Google Inc.' |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 46 | }, |
| 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 Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 55 | } |
| 56 | }; |
| 57 | |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 58 | fs = new FnService(ar, log, mockWindow); |
| 59 | |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 60 | TestBed.configureTestingModule({ |
| 61 | providers: [ZoomableDirective, |
Sean Condon | 0d064ec | 2019-02-04 21:53:53 +0000 | [diff] [blame] | 62 | { provide: FnService, useValue: fs }, |
| 63 | { provide: LogService, useValue: log }, |
| 64 | { provide: 'Window', useValue: mockWindow }, |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 65 | { 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 | }); |