2016-11-10 17:46:23 -05:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
2017-03-02 15:12:46 -05:00
|
|
|
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
2016-11-10 17:46:23 -05:00
|
|
|
import {HammerGestureConfig, HammerGesturesPlugin} from '@angular/platform-browser/src/dom/events/hammer_gestures';
|
|
|
|
|
2017-12-16 17:42:55 -05:00
|
|
|
{
|
2016-11-10 17:46:23 -05:00
|
|
|
describe('HammerGesturesPlugin', () => {
|
2018-02-17 08:00:05 -05:00
|
|
|
let plugin: HammerGesturesPlugin;
|
|
|
|
let mockConsole: any;
|
2017-12-18 01:18:50 -05:00
|
|
|
if (isNode) return;
|
2016-11-10 17:46:23 -05:00
|
|
|
|
2018-02-17 08:00:05 -05:00
|
|
|
beforeEach(() => {
|
|
|
|
mockConsole = {warn: () => {}};
|
|
|
|
plugin = new HammerGesturesPlugin(document, new HammerGestureConfig(), mockConsole);
|
|
|
|
});
|
2016-11-10 17:46:23 -05:00
|
|
|
|
2018-02-17 08:00:05 -05:00
|
|
|
it('should implement addGlobalEventListener', () => {
|
2016-11-10 17:46:23 -05:00
|
|
|
spyOn(plugin, 'addEventListener').and.callFake(() => {});
|
|
|
|
|
|
|
|
expect(() => plugin.addGlobalEventListener('document', 'swipe', () => {})).not.toThrowError();
|
|
|
|
});
|
2018-02-17 08:00:05 -05:00
|
|
|
|
|
|
|
it('shoud warn user and do nothing when Hammer.js not loaeded', () => {
|
|
|
|
spyOn(mockConsole, 'warn');
|
|
|
|
|
|
|
|
expect(plugin.supports('swipe')).toBe(false);
|
|
|
|
expect(mockConsole.warn)
|
|
|
|
.toHaveBeenCalledWith(`Hammer.js is not loaded, can not bind 'swipe' event.`);
|
|
|
|
});
|
2016-11-10 17:46:23 -05:00
|
|
|
});
|
|
|
|
}
|