|
9 | 9 | import expect from 'expect'; |
10 | 10 |
|
11 | 11 | import { |
12 | | - LPonDockClosedEpic |
| 12 | + LPonDockClosedEpic, |
| 13 | + LPclickToProfileEpic |
13 | 14 | } from '../longitudinalProfile'; |
14 | 15 |
|
15 | 16 | import { testEpic } from './epicTestUtils'; |
16 | 17 | import { setControlProperty } from '../../actions/controls'; |
17 | 18 | import { CONTROL_DOCK_NAME, CONTROL_NAME, LONGITUDINAL_OWNER, LONGITUDINAL_VECTOR_LAYER_ID, LONGITUDINAL_VECTOR_LAYER_ID_POINT } from '../../plugins/longitudinalProfile/constants'; |
18 | 19 | import { CHANGE_GEOMETRY } from '../../actions/longitudinalProfile'; |
19 | 20 | import { REMOVE_ADDITIONAL_LAYER } from '../../actions/additionallayers'; |
20 | | -import { UNREGISTER_EVENT_LISTENER } from '../../actions/map'; |
| 21 | +import { UNREGISTER_EVENT_LISTENER, CLICK_ON_MAP } from '../../actions/map'; |
21 | 22 | import { CHANGE_DRAWING_STATUS } from '../../actions/draw'; |
| 23 | +import { SHOW_NOTIFICATION } from '../../actions/notifications'; |
22 | 24 |
|
23 | 25 | describe('longitudinalProfile Epics', () => { |
24 | 26 | it('test default LPonDockClosedEpic epic', (done) => { |
@@ -88,4 +90,50 @@ describe('longitudinalProfile Epics', () => { |
88 | 90 | } |
89 | 91 | }); |
90 | 92 | }); |
| 93 | + |
| 94 | + it('LPclickToProfileEpic should not process clicks when in draw mode', (done) => { |
| 95 | + const NUM_ACTIONS = 0; |
| 96 | + const point = { latlng: { lat: 44.0, lng: 5.0 } }; |
| 97 | + const startActions = [{ type: CLICK_ON_MAP, point }]; |
| 98 | + |
| 99 | + testEpic(LPclickToProfileEpic, NUM_ACTIONS, startActions, actions => { |
| 100 | + expect(actions.length).toBe(0); |
| 101 | + done(); |
| 102 | + }, { |
| 103 | + longitudinalProfile: { |
| 104 | + mode: 'draw' |
| 105 | + }, |
| 106 | + map: { |
| 107 | + present: { |
| 108 | + eventListeners: { |
| 109 | + click: [CONTROL_NAME] |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | + }); |
| 114 | + }); |
| 115 | + |
| 116 | + it('LPclickToProfileEpic should process clicks when in select mode', (done) => { |
| 117 | + const NUM_ACTIONS = 1; |
| 118 | + const point = { latlng: { lat: 44.0, lng: 5.0 } }; |
| 119 | + const startActions = [{ type: CLICK_ON_MAP, point }]; |
| 120 | + |
| 121 | + testEpic(LPclickToProfileEpic, NUM_ACTIONS, startActions, actions => { |
| 122 | + expect(actions.length).toBe(1); |
| 123 | + expect(actions[0].type).toBe(SHOW_NOTIFICATION); |
| 124 | + expect(actions[0].level).toBe('warning'); |
| 125 | + done(); |
| 126 | + }, { |
| 127 | + longitudinalProfile: { |
| 128 | + mode: 'select' |
| 129 | + }, |
| 130 | + map: { |
| 131 | + present: { |
| 132 | + eventListeners: { |
| 133 | + click: [CONTROL_NAME] |
| 134 | + } |
| 135 | + } |
| 136 | + } |
| 137 | + }); |
| 138 | + }); |
91 | 139 | }); |
0 commit comments