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 { DraggableDirective } from './draggable.directive'; |
| 17 | import {inject, TestBed} from '@angular/core/testing'; |
| 18 | import {ElementRef} from '@angular/core'; |
Sean Condon | 3dd062f | 2020-04-14 09:25:00 +0100 | [diff] [blame] | 19 | import {LogService} from 'org_onosproject_onos/web/gui2-fw-lib/public_api'; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 20 | |
| 21 | export class MockElementRef extends ElementRef { |
| 22 | nativeElement = {}; |
| 23 | } |
| 24 | |
| 25 | describe('DraggableDirective', () => { |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 26 | let logServiceSpy: jasmine.SpyObj<LogService>; |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 27 | let mockWindow: Window; |
| 28 | |
| 29 | beforeEach(() => { |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 30 | const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 31 | mockWindow = <any>{ |
| 32 | navigator: { |
| 33 | userAgent: 'HeadlessChrome', |
| 34 | vendor: 'Google Inc.' |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | TestBed.configureTestingModule({ |
| 39 | providers: [DraggableDirective, |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 40 | { provide: LogService, useValue: logSpy }, |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 41 | { provide: 'Window', useFactory: (() => mockWindow ) }, |
| 42 | { provide: ElementRef, useValue: mockWindow } |
| 43 | ] |
| 44 | }); |
Sean Condon | 7191054 | 2019-02-16 18:16:42 +0000 | [diff] [blame] | 45 | logServiceSpy = TestBed.get(LogService); |
Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [diff] [blame] | 46 | }); |
| 47 | |
| 48 | it('should create an instance', inject([DraggableDirective], (directive: DraggableDirective) => { |
| 49 | |
| 50 | expect(directive).toBeTruthy(); |
| 51 | })); |
| 52 | }); |