coveo.analytics 2.26.4 → 2.26.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,12 @@ import {
3
3
  SearchPageEvents,
4
4
  PartialDocumentInformation,
5
5
  CustomEventsTypes,
6
- SmartSnippetFeedbackReason,
7
6
  OmniboxSuggestionsMetadata,
8
7
  StaticFilterToggleValueMetadata,
9
8
  } from './searchPageEvents';
10
9
  import CoveoAnalyticsClient from '../client/analytics';
11
10
  import {NoopAnalytics} from '../client/noopAnalytics';
12
- import {mockFetch} from '../../tests/fetchMock';
11
+ import {mockFetch, lastCallBody} from '../../tests/fetchMock';
13
12
  import doNotTrack from '../donottrack';
14
13
  jest.mock('../donottrack', () => {
15
14
  return {
@@ -114,9 +113,9 @@ describe('SearchPageClient', () => {
114
113
  });
115
114
 
116
115
  const expectMatchPayload = (actionCause: SearchPageEvents, meta = {}) => {
117
- const [, {body}] = fetchMock.lastCall();
116
+ const body: string = lastCallBody(fetchMock);
118
117
  const customData = {foo: 'bar', ...customDataFromMiddleware, ...meta};
119
- expect(JSON.parse(body.toString())).toEqual({
118
+ expect(JSON.parse(body)).toEqual({
120
119
  queryText: 'queryText',
121
120
  responseTime: 123,
122
121
  searchQueryUid: provider.getSearchUID(),
@@ -142,9 +141,9 @@ describe('SearchPageClient', () => {
142
141
  };
143
142
 
144
143
  const expectMatchDocumentPayload = (actionCause: SearchPageEvents, doc: PartialDocumentInformation, meta = {}) => {
145
- const [, {body}] = fetchMock.lastCall();
144
+ const body: string = lastCallBody(fetchMock);
146
145
  const customData = {foo: 'bar', ...customDataFromMiddleware, ...meta};
147
- expect(JSON.parse(body.toString())).toEqual({
146
+ expect(JSON.parse(body)).toEqual({
148
147
  anonymous: false,
149
148
  actionCause,
150
149
  customData,
@@ -164,9 +163,9 @@ describe('SearchPageClient', () => {
164
163
  meta = {},
165
164
  eventType = CustomEventsTypes[actionCause]
166
165
  ) => {
167
- const [, {body}] = fetchMock.lastCall();
166
+ const body: string = lastCallBody(fetchMock);
168
167
  const customData = {foo: 'bar', ...customDataFromMiddleware, ...meta};
169
- expect(JSON.parse(body.toString())).toEqual({
168
+ expect(JSON.parse(body)).toEqual({
170
169
  anonymous: false,
171
170
  eventValue: actionCause,
172
171
  eventType,
@@ -182,9 +181,9 @@ describe('SearchPageClient', () => {
182
181
  };
183
182
 
184
183
  const expectMatchCustomEventWithTypePayload = (eventValue: string, eventType: string, meta = {}) => {
185
- const [, {body}] = fetchMock.lastCall();
184
+ const body: string = lastCallBody(fetchMock);
186
185
  const customData = {foo: 'bar', ...customDataFromMiddleware, ...meta};
187
- expect(JSON.parse(body.toString())).toEqual({
186
+ expect(JSON.parse(body)).toEqual({
188
187
  anonymous: false,
189
188
  eventValue,
190
189
  eventType,