1
+ import { createInstantSearch } from '../../../../test/mock/createInstantSearch' ;
1
2
import {
2
- createSendEventForHits ,
3
3
createBindEventForHits ,
4
+ createSendEventForHits ,
4
5
} from '../createSendEventForHits' ;
5
- import { createInstantSearch } from '../../../../test/mock/createInstantSearch' ;
6
6
7
7
const createTestEnvironment = ( ) => {
8
8
const instantSearchInstance = createInstantSearch ( ) ;
@@ -93,6 +93,13 @@ describe('createSendEventForHits', () => {
93
93
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledTimes ( 1 ) ;
94
94
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledWith ( {
95
95
eventType : 'view' ,
96
+ hits : [
97
+ {
98
+ __position : 0 ,
99
+ __queryID : 'test-query-id' ,
100
+ objectID : 'obj0' ,
101
+ } ,
102
+ ] ,
96
103
insightsMethod : 'viewedObjectIDs' ,
97
104
payload : {
98
105
eventName : 'Hits Viewed' ,
@@ -109,6 +116,13 @@ describe('createSendEventForHits', () => {
109
116
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledTimes ( 1 ) ;
110
117
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledWith ( {
111
118
eventType : 'view' ,
119
+ hits : [
120
+ {
121
+ __position : 0 ,
122
+ __queryID : 'test-query-id' ,
123
+ objectID : 'obj0' ,
124
+ } ,
125
+ ] ,
112
126
insightsMethod : 'viewedObjectIDs' ,
113
127
payload : {
114
128
eventName : 'Products Displayed' ,
@@ -125,6 +139,18 @@ describe('createSendEventForHits', () => {
125
139
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledTimes ( 1 ) ;
126
140
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledWith ( {
127
141
eventType : 'view' ,
142
+ hits : [
143
+ {
144
+ __position : 0 ,
145
+ __queryID : 'test-query-id' ,
146
+ objectID : 'obj0' ,
147
+ } ,
148
+ {
149
+ __position : 1 ,
150
+ __queryID : 'test-query-id' ,
151
+ objectID : 'obj1' ,
152
+ } ,
153
+ ] ,
128
154
insightsMethod : 'viewedObjectIDs' ,
129
155
payload : {
130
156
eventName : 'Hits Viewed' ,
@@ -141,6 +167,13 @@ describe('createSendEventForHits', () => {
141
167
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledTimes ( 1 ) ;
142
168
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledWith ( {
143
169
eventType : 'click' ,
170
+ hits : [
171
+ {
172
+ __position : 0 ,
173
+ __queryID : 'test-query-id' ,
174
+ objectID : 'obj0' ,
175
+ } ,
176
+ ] ,
144
177
insightsMethod : 'clickedObjectIDsAfterSearch' ,
145
178
payload : {
146
179
eventName : 'Product Clicked' ,
@@ -159,6 +192,13 @@ describe('createSendEventForHits', () => {
159
192
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledTimes ( 1 ) ;
160
193
expect ( instantSearchInstance . sendEventToInsights ) . toHaveBeenCalledWith ( {
161
194
eventType : 'conversion' ,
195
+ hits : [
196
+ {
197
+ __position : 0 ,
198
+ __queryID : 'test-query-id' ,
199
+ objectID : 'obj0' ,
200
+ } ,
201
+ ] ,
162
202
insightsMethod : 'convertedObjectIDsAfterSearch' ,
163
203
payload : {
164
204
eventName : 'Product Ordered' ,
@@ -197,6 +237,13 @@ describe('createBindEventForHits', () => {
197
237
) ;
198
238
expect ( parsedPayload ) . toEqual ( {
199
239
eventType : 'click' ,
240
+ hits : [
241
+ {
242
+ __position : 0 ,
243
+ __queryID : 'test-query-id' ,
244
+ objectID : 'obj0' ,
245
+ } ,
246
+ ] ,
200
247
insightsMethod : 'clickedObjectIDsAfterSearch' ,
201
248
payload : {
202
249
eventName : 'Product Clicked' ,
@@ -216,6 +263,13 @@ describe('createBindEventForHits', () => {
216
263
) ;
217
264
expect ( parsedPayload ) . toEqual ( {
218
265
eventType : 'conversion' ,
266
+ hits : [
267
+ {
268
+ __position : 0 ,
269
+ __queryID : 'test-query-id' ,
270
+ objectID : 'obj0' ,
271
+ } ,
272
+ ] ,
219
273
insightsMethod : 'convertedObjectIDsAfterSearch' ,
220
274
payload : {
221
275
eventName : 'Product Ordered' ,
0 commit comments