@simplybusiness/services 0.26.3 → 0.26.4

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/index.js +19 -18
  3. package/dist/esm/index.js +19 -18
  4. package/dist/tsconfig.tsbuildinfo +1 -0
  5. package/dist/types/address-lookup/index.d.ts +1 -1
  6. package/dist/types/mocks/eventDefinitions.d.ts +1 -1
  7. package/dist/types/snowplow/Snowplow.d.ts +5 -5
  8. package/dist/types/snowplow/SnowplowContext.d.ts +1 -1
  9. package/dist/types/snowplow/contexts.d.ts +1 -1
  10. package/dist/types/snowplow/event-definitions/base.d.ts +1 -1
  11. package/dist/types/snowplow/event-definitions/intervention.d.ts +1 -1
  12. package/dist/types/snowplow/event-definitions/personalised_cover.d.ts +1 -1
  13. package/dist/types/snowplow/event-definitions/qcp.d.ts +1 -1
  14. package/dist/types/snowplow/event-definitions/questionnaire.d.ts +1 -1
  15. package/dist/types/snowplow/event-definitions/redaction.d.ts +1 -1
  16. package/dist/types/snowplow/event-definitions/referral.d.ts +1 -1
  17. package/dist/types/snowplow/types.d.ts +1 -1
  18. package/dist/types/utils/testUtils.d.ts +2 -2
  19. package/package.json +20 -18
  20. package/src/address-lookup/index.test.ts +1 -0
  21. package/src/address-lookup/index.ts +13 -12
  22. package/src/mocks/eventDefinitions.ts +6 -6
  23. package/src/mocks/snowplowBrowserTrackerMock.js +1 -0
  24. package/src/snowplow/Snowplow.ts +15 -16
  25. package/src/snowplow/SnowplowContext.test.tsx +1 -1
  26. package/src/snowplow/SnowplowContext.tsx +5 -5
  27. package/src/snowplow/contexts.test.ts +1 -1
  28. package/src/snowplow/contexts.ts +1 -1
  29. package/src/snowplow/event-definitions/base.ts +1 -1
  30. package/src/snowplow/event-definitions/intervention.ts +1 -1
  31. package/src/snowplow/event-definitions/personalised_cover.ts +1 -1
  32. package/src/snowplow/event-definitions/qcp.ts +1 -1
  33. package/src/snowplow/event-definitions/questionnaire.ts +1 -1
  34. package/src/snowplow/event-definitions/redaction.ts +2 -2
  35. package/src/snowplow/event-definitions/referral.ts +1 -1
  36. package/src/snowplow/index.test.ts +35 -26
  37. package/src/snowplow/types.ts +1 -1
  38. package/src/utils/isObject.test.tsx +1 -0
  39. package/src/utils/isObject.tsx +7 -7
  40. package/src/utils/testUtils.tsx +4 -3
  41. package/src/utils/text.test.ts +1 -5
  42. package/src/utils/text.ts +0 -1
  43. package/dist/cjs/tsconfig.tsbuildinfo +0 -1
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  AddressError,
3
3
  AddressLookupConfig,
4
4
  FindAddressResponse,
@@ -31,46 +31,47 @@ export class AddressLookup {
31
31
  this.apiKey = apiKey;
32
32
  this.limit = limit || LIMIT;
33
33
  this.countries = countries || COUNTRIES;
34
- this.findUrl = `${FIND_URL}?Key=${this.apiKey}&Limit=${this.limit}&Countries=${this.countries}`;
34
+ const countriesParam = this.countries.join(",");
35
+ this.findUrl = `${FIND_URL}?Key=${this.apiKey}&Limit=${this.limit}&Countries=${countriesParam}`;
35
36
  this.retrieveUrl = `${RETRIEVE_URL}?Key=${this.apiKey}`;
36
37
  }
37
38
 
38
- private static async fetchFromApi(
39
+ private static async fetchFromApi<RespType>(
39
40
  url: string,
40
- handleResponse: Function,
41
+ handleResponse: (data: RespType) => unknown,
41
42
  ): Promise<unknown> {
42
43
  return new Promise((resolve, reject) => {
43
44
  fetch(url)
44
- .then(response => response.json())
45
+ .then(response => response.json() as Promise<RespType>)
45
46
  .then(data => resolve(handleResponse(data)))
46
- .catch(error => reject(Error(error)));
47
+ .catch(error => reject(Error(String(error))));
47
48
  });
48
49
  }
49
50
 
50
51
  public find(partialAddress: string): Promise<Options> {
51
52
  return new Promise((resolve, reject) => {
52
53
  fetch(`${this.findUrl}&Text=${partialAddress}`)
53
- .then(response => response.json())
54
+ .then(response => response.json() as Promise<FindAddressResponse>)
54
55
  .then(data => resolve(this.formatItems(data)))
55
- .catch(error => reject(Error(error)));
56
+ .catch(error => reject(Error(String(error))));
56
57
  });
57
58
  }
58
59
 
59
60
  public findById(id: string): Promise<Options> {
60
61
  return new Promise((resolve, reject) => {
61
62
  fetch(`${this.findUrl}&Container=${id}`)
62
- .then(response => response.json())
63
+ .then(response => response.json() as Promise<FindAddressResponse>)
63
64
  .then(data => resolve(this.formatItems(data)))
64
- .catch(error => reject(Error(error)));
65
+ .catch(error => reject(Error(String(error))));
65
66
  });
66
67
  }
67
68
 
68
69
  public get(id: string): Promise<Record<string, string>> {
69
70
  return new Promise((resolve, reject) => {
70
71
  fetch(`${this.retrieveUrl}&Id=${id}`)
71
- .then(response => response.json())
72
+ .then(response => response.json() as Promise<RetrieveAddressResponse>)
72
73
  .then(data => resolve(AddressLookup.formatUkAddress(data)))
73
- .catch(error => reject(Error(error)));
74
+ .catch(error => reject(Error(String(error))));
74
75
  });
75
76
  }
76
77
 
@@ -1,4 +1,4 @@
1
- import { ParamsType } from "../snowplow";
1
+ import type { ParamsType } from "../snowplow";
2
2
  import { redact } from "../snowplow/event-definitions/redaction";
3
3
 
4
4
  export default [
@@ -19,8 +19,8 @@ export default [
19
19
  name: "questionAnswered",
20
20
  type: "unstructured",
21
21
  makePayload: (params: ParamsType) => {
22
- const { section, context } = params as ParamsType;
23
- const { question, answer } = redact(params as ParamsType);
22
+ const { section, context } = params;
23
+ const { question, answer } = redact(params);
24
24
 
25
25
  return {
26
26
  schema:
@@ -43,7 +43,7 @@ export default [
43
43
  name: "primaryDetailSelected",
44
44
  type: "unstructured",
45
45
  makePayload: (params: ParamsType) => {
46
- const { context, answer, vertical } = params as ParamsType;
46
+ const { context, answer, vertical } = params;
47
47
  const { site } = context;
48
48
  let verticalName = vertical || context.vertical;
49
49
 
@@ -59,7 +59,7 @@ export default [
59
59
  site,
60
60
  vertical: verticalName,
61
61
  primary_detail: answer,
62
- selected_type: 'trade_selector',
62
+ selected_type: "trade_selector",
63
63
  },
64
64
  };
65
65
  },
@@ -68,7 +68,7 @@ export default [
68
68
  name: "helpTextOpened",
69
69
  type: "unstructured",
70
70
  makePayload: (params: ParamsType) => {
71
- const { primaryText, label, context, helpText } = params as ParamsType;
71
+ const { primaryText, label, context, helpText } = params;
72
72
 
73
73
  return {
74
74
  schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-undef */
1
2
  /**
2
3
  * Mocking this module prevents requests being sent to
3
4
  * Snowplow which causes CORS errors in the test enviornment.
@@ -1,7 +1,9 @@
1
- import {
1
+ import type {
2
2
  PageViewEvent,
3
3
  StructuredEvent,
4
4
  TrackerConfiguration,
5
+ } from "@snowplow/browser-tracker";
6
+ import {
5
7
  newTracker,
6
8
  setCookiePath,
7
9
  setUserId,
@@ -10,7 +12,7 @@ import {
10
12
  trackStructEvent,
11
13
  } from "@snowplow/browser-tracker";
12
14
  import { makeContexts, updateIdentityContext } from "./contexts";
13
- import { EventDefinition, SerialisedEvent, TrackingProps } from "./types";
15
+ import type { EventDefinition, SerialisedEvent, TrackingProps } from "./types";
14
16
 
15
17
  export type FrontOfficeStructuredEvent = StructuredEvent & {
16
18
  serviceChannelIdentifier: string;
@@ -105,9 +107,9 @@ export class Snowplow {
105
107
  }
106
108
 
107
109
  // Send a page view event
108
- async trackView(event?: PageViewEvent) {
110
+ trackView(event?: PageViewEvent) {
109
111
  if (this.trackPageView) {
110
- await trackPageView({ ...event, context: this.pvContext }, [
112
+ trackPageView({ ...event, context: this.pvContext }, [
111
113
  this.avalancheTrackerName,
112
114
  ]);
113
115
  }
@@ -115,28 +117,25 @@ export class Snowplow {
115
117
  }
116
118
 
117
119
  // Send a structured event with contexts
118
- async trackEvent(event: StructuredEvent) {
119
- await trackStructEvent({ ...event, context: this.structContext }, [
120
+ trackEvent(event: StructuredEvent) {
121
+ trackStructEvent({ ...event, context: this.structContext }, [
120
122
  this.bronzeAvalancheTrackerName,
121
123
  ]);
122
124
  return this;
123
125
  }
124
126
 
125
127
  // Send a custom event with defined schema and optional contexts
126
- async trackUnstructEvent(event: SerialisedEvent, contexts?: string[]) {
128
+ trackUnstructEvent(event: SerialisedEvent, contexts?: string[]) {
127
129
  if (!event) {
128
130
  return this;
129
131
  }
130
132
 
131
133
  if (contexts && Array.isArray(contexts) && contexts.length > 0) {
132
134
  // Add context to the event
133
- const context = makeContexts(contexts!, this.contexts);
134
-
135
- await trackSelfDescribingEvent({ event, context }, [
136
- this.avalancheTrackerName,
137
- ]);
135
+ const context = makeContexts(contexts, this.contexts);
136
+ trackSelfDescribingEvent({ event, context }, [this.avalancheTrackerName]);
138
137
  } else {
139
- await trackSelfDescribingEvent({ event }, [this.avalancheTrackerName]);
138
+ trackSelfDescribingEvent({ event }, [this.avalancheTrackerName]);
140
139
  }
141
140
  return this;
142
141
  }
@@ -149,7 +148,7 @@ export class Snowplow {
149
148
  // Convert type into relevant function
150
149
  if (type === "structured") {
151
150
  this.addEventHandler(name, (params?: Record<string, unknown>) => {
152
- this.trackEvent(
151
+ void this.trackEvent(
153
152
  makePayload({
154
153
  ...params,
155
154
  context,
@@ -164,9 +163,9 @@ export class Snowplow {
164
163
  }) as SerialisedEvent;
165
164
 
166
165
  if (contexts && Array.isArray(contexts) && contexts.length > 0) {
167
- this.trackUnstructEvent(payload, contexts);
166
+ void this.trackUnstructEvent(payload, contexts);
168
167
  } else {
169
- this.trackUnstructEvent(payload);
168
+ void this.trackUnstructEvent(payload);
170
169
  }
171
170
  });
172
171
  }
@@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react";
2
2
  import { pageData } from "../mocks/scripts-mock";
3
3
  import { getSnowplowConfig } from "./getSnowplowConfig";
4
4
  import { SnowplowProvider } from "./SnowplowContext";
5
- import { PageDataProps } from "./types";
5
+ import type { PageDataProps } from "./types";
6
6
 
7
7
  const pageDataWithoutScripts = {
8
8
  ...pageData,
@@ -11,7 +11,7 @@ import {
11
11
  import { getContexts } from "./contexts";
12
12
  import { eventDefinitions } from "./event-definitions";
13
13
  import { Snowplow } from "./Snowplow";
14
- import { EventDefinition, TrackingProps } from "./types";
14
+ import type { EventDefinition, TrackingProps } from "./types";
15
15
 
16
16
  export interface SnowplowContextInterface {
17
17
  config: TrackingProps;
@@ -34,11 +34,11 @@ export const SnowplowProvider = ({ scripts, children }: ProviderProps) => {
34
34
  if (snowplow.current && scripts) {
35
35
  const contexts = getContexts(config);
36
36
 
37
- snowplow.current
38
- .setContexts(contexts)
39
- .addEventHandlers(eventDefinitions as EventDefinition[]);
37
+ snowplow.current.setContexts(contexts).addEventHandlers(eventDefinitions);
40
38
  // Send page view event
41
- if (config.trackPageView) snowplow.current.trackView();
39
+ if (config.trackPageView) {
40
+ void snowplow.current.trackView();
41
+ }
42
42
  }
43
43
  }, [config, snowplow, scripts]);
44
44
 
@@ -1,7 +1,7 @@
1
1
  import { pageData } from "../mocks/scripts-mock";
2
2
  import { getContexts, makeContexts, updateIdentityContext } from "./contexts";
3
3
  import { getSnowplowConfig } from "./getSnowplowConfig";
4
- import { PageDataProps, TrackingProps } from "./types";
4
+ import type { PageDataProps, TrackingProps } from "./types";
5
5
 
6
6
  describe("Snowplow Contexts", () => {
7
7
  it("should extract all context records from snowplow props", () => {
@@ -1,5 +1,5 @@
1
1
  import { snakeCaseKeys } from "../utils";
2
- import { SerialisedEvent, TrackingProps } from "./types";
2
+ import type { SerialisedEvent, TrackingProps } from "./types";
3
3
 
4
4
  export const getContexts = (
5
5
  config: TrackingProps,
@@ -1,4 +1,4 @@
1
- import { EventDefinition, ParamsType } from "../types";
1
+ import type { EventDefinition, ParamsType } from "../types";
2
2
  /**
3
3
  * Event definitions for Snowplow
4
4
  * @type {EventDefinition[]}
@@ -1,4 +1,4 @@
1
- import { EventDefinition } from "../types";
1
+ import type { EventDefinition } from "../types";
2
2
 
3
3
  type InterventionIdTypes = "duid"; // Add more values as needed
4
4
 
@@ -1,4 +1,4 @@
1
- import { EventDefinition, ParamsType } from "../types";
1
+ import type { EventDefinition, ParamsType } from "../types";
2
2
  import { redact } from "./redaction";
3
3
  import { DELIMITER } from "../constants";
4
4
  import { snakeCase } from "../../utils";
@@ -1,5 +1,5 @@
1
1
  import { snakeCase } from "../../utils";
2
- import { EventDefinition, LinkType, ParamsType } from "../types";
2
+ import type { EventDefinition, LinkType, ParamsType } from "../types";
3
3
 
4
4
  // QCP page events
5
5
  export const qcpEventDefinitions: EventDefinition[] = [
@@ -1,5 +1,5 @@
1
1
  import { DELIMITER } from "../constants";
2
- import { EventDefinition, ParamsType } from "../types";
2
+ import type { EventDefinition, ParamsType } from "../types";
3
3
  import { redact } from "./redaction";
4
4
 
5
5
  // Questionnaire events
@@ -1,4 +1,4 @@
1
- import { ParamsType } from "../types";
1
+ import type { ParamsType } from "../types";
2
2
 
3
3
  const PII_ANSWER = [
4
4
  "customer_title",
@@ -131,7 +131,7 @@ const RADIO_ANSWER_FROM_QUESTIONS = [
131
131
  const ANSWER_SUFFIX_PATTERN = /_(yes|no)$/;
132
132
 
133
133
  export const redact = (params: ParamsType) => {
134
- let { question, answer } = params as ParamsType;
134
+ let { question, answer } = params;
135
135
 
136
136
  const piiAnswer = new Set(PII_ANSWER);
137
137
  const radioAnswerFromQuestions = new Set(RADIO_ANSWER_FROM_QUESTIONS);
@@ -1,4 +1,4 @@
1
- import { EventDefinition, ParamsType } from "../types";
1
+ import type { EventDefinition, ParamsType } from "../types";
2
2
 
3
3
  // Referral page events
4
4
  export const referralEventDefinitions: EventDefinition[] = [
@@ -1,11 +1,11 @@
1
1
  import * as SnowplowLib from "@snowplow/browser-tracker";
2
- import { waitFor } from "@testing-library/dom";
2
+ import { waitFor } from "@testing-library/react";
3
3
  import eventDefinitions from "../mocks/eventDefinitions";
4
4
  import { pageData } from "../mocks/scripts-mock";
5
5
  import { getContexts, makeContexts } from "./contexts";
6
6
  import { getSnowplowConfig } from "./getSnowplowConfig";
7
7
  import { Snowplow } from "./Snowplow";
8
- import { EventDefinition, PageDataProps, TrackingProps } from "./types";
8
+ import type { EventDefinition, PageDataProps, TrackingProps } from "./types";
9
9
 
10
10
  const snowplowProps = getSnowplowConfig(pageData as PageDataProps);
11
11
  const contexts = getContexts(snowplowProps as TrackingProps);
@@ -49,17 +49,26 @@ describe("Snowplow Analytics Class", () => {
49
49
  .spyOn(SnowplowLib, "trackPageView")
50
50
  .mockImplementation(() => {});
51
51
 
52
- await testSnowplow.trackView();
52
+ testSnowplow.trackView();
53
53
 
54
- waitFor(() => {
54
+ await waitFor(() => {
55
55
  expect(trackViewSpy).toHaveBeenCalledTimes(1);
56
+ });
57
+ await waitFor(() => {
56
58
  expect(trackViewSpy).toHaveBeenCalledWith();
59
+ });
60
+ await waitFor(() => {
57
61
  expect(innerSpy).toHaveBeenCalledTimes(1);
58
- expect(innerSpy).toHaveBeenCalledWith({});
62
+ });
63
+ await waitFor(() => {
64
+ expect(innerSpy).toHaveBeenCalledWith(
65
+ { context: testSnowplow.pvContext },
66
+ ["sb-ava"],
67
+ );
59
68
  });
60
69
  });
61
70
 
62
- it("tracks structured event and adds contexts", async () => {
71
+ it("tracks structured event and adds contexts", () => {
63
72
  const trackStructEventSpy = jest.spyOn(testSnowplow, "trackEvent");
64
73
  const innerSpy = jest
65
74
  .spyOn(SnowplowLib, "trackStructEvent")
@@ -71,7 +80,7 @@ describe("Snowplow Analytics Class", () => {
71
80
  label: "test-label",
72
81
  };
73
82
 
74
- await testSnowplow.trackEvent(payload);
83
+ testSnowplow.trackEvent(payload);
75
84
 
76
85
  expect(trackStructEventSpy).toHaveBeenCalledTimes(1);
77
86
  expect(trackStructEventSpy).toHaveBeenCalledWith(payload);
@@ -82,7 +91,7 @@ describe("Snowplow Analytics Class", () => {
82
91
  );
83
92
  });
84
93
 
85
- it("tracks self-describing event and adds contexts", async () => {
94
+ it("tracks self-describing event and adds contexts", () => {
86
95
  const trackUnstructEventSpy = jest.spyOn(
87
96
  testSnowplow,
88
97
  "trackUnstructEvent",
@@ -102,7 +111,7 @@ describe("Snowplow Analytics Class", () => {
102
111
  },
103
112
  };
104
113
 
105
- await testSnowplow.trackUnstructEvent(testEvent);
114
+ testSnowplow.trackUnstructEvent(testEvent);
106
115
  expect(trackUnstructEventSpy).toHaveBeenCalledTimes(1);
107
116
  expect(trackUnstructEventSpy).toHaveBeenCalledWith(testEvent);
108
117
  expect(innerSpy).toHaveBeenCalledTimes(1);
@@ -125,7 +134,7 @@ describe("Snowplow Analytics Class", () => {
125
134
  ]);
126
135
  });
127
136
 
128
- it("triggers an added structured event", async () => {
137
+ it("triggers an added structured event", () => {
129
138
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
130
139
 
131
140
  const trackStructEventSpy = jest.spyOn(testSnowplow, "trackEvent");
@@ -133,7 +142,7 @@ describe("Snowplow Analytics Class", () => {
133
142
  .spyOn(SnowplowLib, "trackStructEvent")
134
143
  .mockImplementation(() => {});
135
144
 
136
- await testSnowplow.trigger("navButtonClicked", { label: "test-label" });
145
+ testSnowplow.trigger("navButtonClicked", { label: "test-label" });
137
146
 
138
147
  const expectedPayload = {
139
148
  category: "navigation",
@@ -151,7 +160,7 @@ describe("Snowplow Analytics Class", () => {
151
160
  );
152
161
  });
153
162
 
154
- it("triggers an added unstructured event", async () => {
163
+ it("triggers an added unstructured event", () => {
155
164
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
156
165
 
157
166
  const trackUnstructEventSpy = jest.spyOn(
@@ -162,7 +171,7 @@ describe("Snowplow Analytics Class", () => {
162
171
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
163
172
  .mockImplementation(() => {});
164
173
 
165
- await testSnowplow.trigger("questionAnswered", {
174
+ testSnowplow.trigger("questionAnswered", {
166
175
  question: "test-question",
167
176
  section: "test-section",
168
177
  answer: "test-answer",
@@ -197,7 +206,7 @@ describe("Snowplow Analytics Class", () => {
197
206
  );
198
207
  });
199
208
 
200
- it("triggers an added unstructured event and readact the pii information and replace question name", async () => {
209
+ it("triggers an added unstructured event and readact the pii information and replace question name", () => {
201
210
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
202
211
 
203
212
  const trackUnstructEventSpy = jest.spyOn(
@@ -208,7 +217,7 @@ describe("Snowplow Analytics Class", () => {
208
217
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
209
218
  .mockImplementation(() => {});
210
219
 
211
- await testSnowplow.trigger("questionAnswered", {
220
+ testSnowplow.trigger("questionAnswered", {
212
221
  question: "sof_bankrupt_yes",
213
222
  section: "agreements",
214
223
  answer: "Yes",
@@ -243,7 +252,7 @@ describe("Snowplow Analytics Class", () => {
243
252
  );
244
253
  });
245
254
 
246
- it("triggers an added unstructured event and replace radio answer from questions", async () => {
255
+ it("triggers an added unstructured event and replace radio answer from questions", () => {
247
256
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
248
257
 
249
258
  const trackUnstructEventSpy = jest.spyOn(
@@ -254,7 +263,7 @@ describe("Snowplow Analytics Class", () => {
254
263
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
255
264
  .mockImplementation(() => {});
256
265
 
257
- await testSnowplow.trigger("questionAnswered", {
266
+ testSnowplow.trigger("questionAnswered", {
258
267
  question: "have_secondary_trade_yes",
259
268
  section: "about_your_business",
260
269
  answer: "Yes",
@@ -289,7 +298,7 @@ describe("Snowplow Analytics Class", () => {
289
298
  );
290
299
  });
291
300
 
292
- it("triggers an added unstructured event for address lookup type questions", async () => {
301
+ it("triggers an added unstructured event for address lookup type questions", () => {
293
302
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
294
303
 
295
304
  const trackUnstructEventSpy = jest.spyOn(
@@ -300,7 +309,7 @@ describe("Snowplow Analytics Class", () => {
300
309
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
301
310
  .mockImplementation(() => {});
302
311
 
303
- await testSnowplow.trigger("questionAnswered", {
312
+ testSnowplow.trigger("questionAnswered", {
304
313
  question: "address_lookup",
305
314
  section: "about_your_business",
306
315
  answer: "123 Test Street",
@@ -348,7 +357,7 @@ describe("Snowplow Analytics Class", () => {
348
357
  ["Anything", "test", "Anything"],
349
358
  ])(
350
359
  "triggers an primary_detail_selected event %s",
351
- async (initialVertical, answer, vertical) => {
360
+ (initialVertical, answer, vertical) => {
352
361
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
353
362
 
354
363
  const trackUnstructEventSpy = jest.spyOn(
@@ -359,7 +368,7 @@ describe("Snowplow Analytics Class", () => {
359
368
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
360
369
  .mockImplementation(() => {});
361
370
 
362
- await testSnowplow.trigger("primaryDetailSelected", {
371
+ testSnowplow.trigger("primaryDetailSelected", {
363
372
  answer,
364
373
  vertical: initialVertical,
365
374
  });
@@ -371,7 +380,7 @@ describe("Snowplow Analytics Class", () => {
371
380
  vertical,
372
381
  primary_detail: answer,
373
382
  site: "simplybusiness_us",
374
- selected_type: "trade_selector"
383
+ selected_type: "trade_selector",
375
384
  },
376
385
  };
377
386
 
@@ -387,7 +396,7 @@ describe("Snowplow Analytics Class", () => {
387
396
  },
388
397
  );
389
398
 
390
- it("triggers an added unstructured help_text_opened event", async () => {
399
+ it("triggers an added unstructured help_text_opened event", () => {
391
400
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
392
401
 
393
402
  const trackUnstructEventSpy = jest.spyOn(
@@ -398,7 +407,7 @@ describe("Snowplow Analytics Class", () => {
398
407
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
399
408
  .mockImplementation(() => {});
400
409
 
401
- await testSnowplow.trigger("helpTextOpened", {
410
+ testSnowplow.trigger("helpTextOpened", {
402
411
  primaryText: "Sample text",
403
412
  label: "Sample label",
404
413
  helpText: "Sample help text",
@@ -427,7 +436,7 @@ describe("Snowplow Analytics Class", () => {
427
436
  );
428
437
  });
429
438
 
430
- it("uses server-supplied context in events", async () => {
439
+ it("uses server-supplied context in events", () => {
431
440
  testSnowplow.addEventHandlers(eventDefinitions as EventDefinition[]);
432
441
 
433
442
  const trackUnstructEventSpy = jest.spyOn(
@@ -438,7 +447,7 @@ describe("Snowplow Analytics Class", () => {
438
447
  .spyOn(SnowplowLib, "trackSelfDescribingEvent")
439
448
  .mockImplementation(() => {});
440
449
 
441
- await testSnowplow.trigger("questionAnswered", {
450
+ testSnowplow.trigger("questionAnswered", {
442
451
  question: "test-question",
443
452
  section: "test-section",
444
453
  answer: "test-answer",
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  EventMethod,
3
3
  SelfDescribingJson,
4
4
  StructuredEvent,
@@ -29,6 +29,7 @@ describe("isObject", () => {
29
29
  });
30
30
 
31
31
  it("should return false for objects with different prototypes", () => {
32
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
32
33
  const obj = Object.create(null);
33
34
  expect(isObject(obj)).toBeFalsy();
34
35
  });
@@ -1,8 +1,8 @@
1
1
  export function isObject(value: unknown): value is Record<string, unknown> {
2
- return (
3
- typeof value === "object" &&
4
- value !== null &&
5
- !Array.isArray(value) &&
6
- Object.getPrototypeOf(value) === Object.prototype
7
- );
8
- }
2
+ return (
3
+ typeof value === "object" &&
4
+ value !== null &&
5
+ !Array.isArray(value) &&
6
+ Object.getPrototypeOf(value) === Object.prototype
7
+ );
8
+ }
@@ -1,10 +1,11 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
- import { RenderOptions, render } from "@testing-library/react";
3
- import { ReactElement, ReactNode } from "react";
2
+ import type { RenderOptions } from "@testing-library/react";
3
+ import { render } from "@testing-library/react";
4
+ import type { ReactElement, ReactNode } from "react";
4
5
  import { pageData } from "../mocks/scripts-mock";
5
6
  import { SnowplowProvider } from "../snowplow/SnowplowContext";
6
7
  import { getSnowplowConfig } from "../snowplow/getSnowplowConfig";
7
- import { PageDataProps } from "../snowplow/types";
8
+ import type { PageDataProps } from "../snowplow/types";
8
9
 
9
10
  // Snowplow analytics
10
11
  const snowplowProps = getSnowplowConfig(pageData as PageDataProps);
@@ -1,8 +1,4 @@
1
- import {
2
- camelToSnakeCase,
3
- snakeCase,
4
- snakeCaseKeys,
5
- } from "./text";
1
+ import { camelToSnakeCase, snakeCase, snakeCaseKeys } from "./text";
6
2
 
7
3
  describe("text utils", () => {
8
4
  test("snakeCase", () => {
package/src/utils/text.ts CHANGED
@@ -38,4 +38,3 @@ export const camelToSnakeCase = (text: string) =>
38
38
  .replace(/(\[.*?\])|[A-Z]/g, (match, group) =>
39
39
  group ? match : `_${match.toLowerCase()}`,
40
40
  );
41
-