UNPKG

811 BTypeScriptView Raw
1import * as React from 'react';
2import layerMouseTouchEvents from '../layer-events-hoc';
3import { MockComponent, mountWithMap, getMapMock } from '../jest/util';
4import { withMap } from '../context';
5
6const LayerHOC = withMap(layerMouseTouchEvents(MockComponent));
7
8describe('layer-events-hoc', () => {
9 it('Should default the id if none is passed', () => {
10 const res = mountWithMap(<LayerHOC />, getMapMock());
11 expect(res.find('h1').text()).toBe('layer-1');
12 });
13
14 it('should listen all mouse and touch events', () => {
15 const mapMock = getMapMock();
16 mountWithMap(<LayerHOC />, mapMock);
17
18 const events = [
19 'click',
20 'mouseenter',
21 'mouseleave',
22 'mousedown',
23 'touchstart'
24 ];
25
26 expect(mapMock.on.mock.calls.map(call => call[0])).toEqual(events);
27 });
28});