blob: 136fb6b5e9d4c9147f7335aac48feb3e0380d026 [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 { DraggableDirective } from './draggable.directive';
17import {inject, TestBed} from '@angular/core/testing';
18import {ElementRef} from '@angular/core';
Sean Condon3dd062f2020-04-14 09:25:00 +010019import {LogService} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Sean Condon0c577f62018-11-18 22:40:05 +000020
21export class MockElementRef extends ElementRef {
22 nativeElement = {};
23}
24
25describe('DraggableDirective', () => {
Sean Condon71910542019-02-16 18:16:42 +000026 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condon0c577f62018-11-18 22:40:05 +000027 let mockWindow: Window;
28
29 beforeEach(() => {
Sean Condon71910542019-02-16 18:16:42 +000030 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
Sean Condon0c577f62018-11-18 22:40:05 +000031 mockWindow = <any>{
32 navigator: {
33 userAgent: 'HeadlessChrome',
34 vendor: 'Google Inc.'
35 }
36 };
37
38 TestBed.configureTestingModule({
39 providers: [DraggableDirective,
Sean Condon71910542019-02-16 18:16:42 +000040 { provide: LogService, useValue: logSpy },
Sean Condon0c577f62018-11-18 22:40:05 +000041 { provide: 'Window', useFactory: (() => mockWindow ) },
42 { provide: ElementRef, useValue: mockWindow }
43 ]
44 });
Sean Condon71910542019-02-16 18:16:42 +000045 logServiceSpy = TestBed.get(LogService);
Sean Condon0c577f62018-11-18 22:40:05 +000046 });
47
48 it('should create an instance', inject([DraggableDirective], (directive: DraggableDirective) => {
49
50 expect(directive).toBeTruthy();
51 }));
52});