@ht-sdks/consent-manager 0.1.0 → 0.2.1

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 (98) hide show
  1. package/commonjs/__tests__/consent-manager/dialog.test.js +33 -0
  2. package/commonjs/__tests__/consent-manager-builder/analytics.test.js +135 -46
  3. package/commonjs/__tests__/consent-manager-builder/index.todo.js +48 -87
  4. package/commonjs/__tests__/consent-manager-builder/preferences.test.js +136 -55
  5. package/commonjs/__tests__/index.test.js +12 -12
  6. package/commonjs/consent-manager/banner.js +35 -19
  7. package/commonjs/consent-manager/buttons.js +5 -5
  8. package/commonjs/consent-manager/cancel-dialog.js +26 -10
  9. package/commonjs/consent-manager/categories.js +2 -2
  10. package/commonjs/consent-manager/container.js +2 -3
  11. package/commonjs/consent-manager/dialog.js +39 -23
  12. package/commonjs/consent-manager/font-styles.js +2 -2
  13. package/commonjs/consent-manager/index.js +41 -25
  14. package/commonjs/consent-manager/preference-dialog.js +36 -20
  15. package/commonjs/consent-manager-builder/analytics.js +19 -7
  16. package/commonjs/consent-manager-builder/index.js +31 -30
  17. package/commonjs/consent-manager-builder/preferences.js +100 -24
  18. package/commonjs/index.js +5 -4
  19. package/commonjs/standalone.js +25 -11
  20. package/esm/__tests__/consent-manager/dialog.test.js +28 -0
  21. package/esm/__tests__/consent-manager-builder/analytics.test.js +123 -34
  22. package/esm/__tests__/consent-manager-builder/index.todo.js +34 -73
  23. package/esm/__tests__/consent-manager-builder/preferences.test.js +135 -54
  24. package/esm/consent-manager/banner.js +5 -3
  25. package/esm/consent-manager/buttons.js +4 -4
  26. package/esm/consent-manager/cancel-dialog.js +4 -2
  27. package/esm/consent-manager/categories.js +2 -2
  28. package/esm/consent-manager/container.js +1 -1
  29. package/esm/consent-manager/dialog.js +7 -5
  30. package/esm/consent-manager/font-styles.js +2 -2
  31. package/esm/consent-manager/index.js +19 -17
  32. package/esm/consent-manager/preference-dialog.js +7 -5
  33. package/esm/consent-manager-builder/analytics.js +18 -6
  34. package/esm/consent-manager-builder/index.js +28 -27
  35. package/esm/consent-manager-builder/preferences.js +96 -20
  36. package/esm/index.js +4 -3
  37. package/esm/standalone.js +3 -3
  38. package/esm/types.js +1 -0
  39. package/package.json +62 -67
  40. package/src/__tests__/consent-manager/dialog.test.tsx +42 -0
  41. package/src/__tests__/consent-manager-builder/analytics.test.ts +75 -33
  42. package/src/__tests__/consent-manager-builder/index.todo.js +52 -95
  43. package/src/__tests__/consent-manager-builder/preferences.test.ts +43 -27
  44. package/src/consent-manager/banner.tsx +11 -11
  45. package/src/consent-manager/buttons.tsx +26 -10
  46. package/src/consent-manager/cancel-dialog.tsx +1 -1
  47. package/src/consent-manager/categories.ts +2 -2
  48. package/src/consent-manager/container.tsx +14 -17
  49. package/src/consent-manager/dialog.tsx +4 -4
  50. package/src/consent-manager/font-styles.tsx +12 -2
  51. package/src/consent-manager/index.tsx +27 -29
  52. package/src/consent-manager/preference-dialog.tsx +13 -11
  53. package/src/consent-manager-builder/analytics.ts +20 -6
  54. package/src/consent-manager-builder/index.tsx +30 -29
  55. package/src/consent-manager-builder/preferences.ts +59 -30
  56. package/src/index.ts +8 -4
  57. package/src/standalone.tsx +1 -1
  58. package/src/types.ts +9 -3
  59. package/standalone/consent-manager.js +5 -10
  60. package/standalone/consent-manager.js.map +1 -1
  61. package/types/consent-manager/banner.d.ts +1 -1
  62. package/types/consent-manager/buttons.d.ts +6 -7
  63. package/types/consent-manager/cancel-dialog.d.ts +1 -1
  64. package/types/consent-manager/index.d.ts +3 -3
  65. package/types/consent-manager/preference-dialog.d.ts +1 -1
  66. package/types/consent-manager-builder/analytics.d.ts +2 -1
  67. package/types/consent-manager-builder/index.d.ts +7 -8
  68. package/types/consent-manager-builder/preferences.d.ts +4 -6
  69. package/types/index.d.ts +1 -1
  70. package/types/types.d.ts +15 -11
  71. package/commonjs/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -155
  72. package/commonjs/consent-manager-builder/fetch-destinations.js +0 -104
  73. package/esm/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -150
  74. package/esm/consent-manager-builder/fetch-destinations.js +0 -98
  75. package/src/__tests__/consent-manager-builder/fetch-destinations.test.ts +0 -89
  76. package/src/consent-manager-builder/fetch-destinations.ts +0 -50
  77. package/types/consent-manager-builder/fetch-destinations.d.ts +0 -2
  78. package/types/src/__tests__/consent-manager-builder/analytics.test.d.ts +0 -1
  79. package/types/src/__tests__/consent-manager-builder/fetch-destinations.test.d.ts +0 -1
  80. package/types/src/__tests__/consent-manager-builder/preferences.test.d.ts +0 -1
  81. package/types/src/__tests__/index.test.d.ts +0 -1
  82. package/types/src/consent-manager/banner.d.ts +0 -21
  83. package/types/src/consent-manager/buttons.d.ts +0 -13
  84. package/types/src/consent-manager/cancel-dialog.d.ts +0 -19
  85. package/types/src/consent-manager/categories.d.ts +0 -3
  86. package/types/src/consent-manager/container.d.ts +0 -35
  87. package/types/src/consent-manager/dialog.d.ts +0 -29
  88. package/types/src/consent-manager/font-styles.d.ts +0 -2
  89. package/types/src/consent-manager/index.d.ts +0 -35
  90. package/types/src/consent-manager/preference-dialog.d.ts +0 -32
  91. package/types/src/consent-manager-builder/analytics.d.ts +0 -14
  92. package/types/src/consent-manager-builder/fetch-destinations.d.ts +0 -2
  93. package/types/src/consent-manager-builder/index.d.ts +0 -126
  94. package/types/src/consent-manager-builder/preferences.d.ts +0 -26
  95. package/types/src/index.d.ts +0 -7
  96. package/types/src/standalone.d.ts +0 -5
  97. package/types/src/types.d.ts +0 -130
  98. /package/types/__tests__/{consent-manager-builder/fetch-destinations.test.d.ts → consent-manager/dialog.test.d.ts} +0 -0
@@ -11,7 +11,7 @@ describe('analytics', () => {
11
11
  wd.htevents = {
12
12
  /*eslint-disable */
13
13
  track: (_event, _properties, _optionsWithConsent, _callback) => {},
14
- addSourceMiddleware: (_middleware: Middleware) => {}
14
+ addSourceMiddleware: (_middleware: Middleware) => {},
15
15
  /*eslint-enable */
16
16
  }
17
17
  })
@@ -22,7 +22,7 @@ describe('analytics', () => {
22
22
  const writeKey = '123'
23
23
  const destinations = [{ id: 'Amplitude' } as Destination]
24
24
  const destinationPreferences = {
25
- Amplitude: true
25
+ Amplitude: true,
26
26
  }
27
27
 
28
28
  conditionallyLoadAnalytics({
@@ -30,7 +30,7 @@ describe('analytics', () => {
30
30
  destinations,
31
31
  destinationPreferences,
32
32
  isConsentRequired: true,
33
- categoryPreferences: {}
33
+ categoryPreferences: {},
34
34
  })
35
35
 
36
36
  expect(hteventsLoad.calledOnce).toBe(true)
@@ -39,8 +39,8 @@ describe('analytics', () => {
39
39
  integrations: {
40
40
  All: false,
41
41
  Amplitude: true,
42
- 'Hightouch.io': true
43
- }
42
+ 'Hightouch.io': true,
43
+ },
44
44
  })
45
45
  })
46
46
 
@@ -56,7 +56,7 @@ describe('analytics', () => {
56
56
  destinations,
57
57
  destinationPreferences,
58
58
  isConsentRequired: true,
59
- categoryPreferences: {}
59
+ categoryPreferences: {},
60
60
  })
61
61
 
62
62
  expect(hteventsLoad.notCalled).toBe(true)
@@ -68,7 +68,7 @@ describe('analytics', () => {
68
68
  const writeKey = '123'
69
69
  const destinations = [{ id: 'Amplitude' } as Destination]
70
70
  const destinationPreferences = {
71
- Amplitude: false
71
+ Amplitude: false,
72
72
  }
73
73
 
74
74
  conditionallyLoadAnalytics({
@@ -76,7 +76,7 @@ describe('analytics', () => {
76
76
  destinations,
77
77
  destinationPreferences,
78
78
  isConsentRequired: true,
79
- categoryPreferences: {}
79
+ categoryPreferences: {},
80
80
  })
81
81
 
82
82
  expect(hteventsLoad.notCalled).toBe(true)
@@ -87,12 +87,16 @@ describe('analytics', () => {
87
87
  this.initialized = true
88
88
  }
89
89
 
90
- jest.spyOn(window.location, 'reload')
90
+ const reload = jest.fn()
91
+ Object.defineProperty(window, 'location', {
92
+ configurable: true,
93
+ value: { reload },
94
+ })
91
95
 
92
96
  const writeKey = '123'
93
97
  const destinations = [{ id: 'Amplitude' } as Destination]
94
98
  const destinationPreferences = {
95
- Amplitude: true
99
+ Amplitude: true,
96
100
  }
97
101
 
98
102
  conditionallyLoadAnalytics({
@@ -100,29 +104,67 @@ describe('analytics', () => {
100
104
  destinations,
101
105
  destinationPreferences,
102
106
  isConsentRequired: true,
103
- categoryPreferences: {}
107
+ categoryPreferences: {},
104
108
  })
105
109
  conditionallyLoadAnalytics({
106
110
  writeKey,
107
111
  destinations,
108
112
  destinationPreferences,
109
113
  isConsentRequired: true,
110
- categoryPreferences: {}
114
+ categoryPreferences: {},
111
115
  })
112
116
 
113
117
  expect(window.location.reload).toHaveBeenCalled()
114
118
  })
115
119
 
120
+ test.each([true, false])(
121
+ 'bounds the consent handoff and reloads once (settles=%s)',
122
+ async (settles) => {
123
+ jest.useFakeTimers()
124
+ try {
125
+ wd.htevents.initialized = true
126
+ const reload = jest.fn()
127
+ Object.defineProperty(window, 'location', { configurable: true, value: { reload } })
128
+ let finish!: () => void
129
+ const consentUpdate = new Promise<void>((resolve) => {
130
+ finish = resolve
131
+ })
132
+ conditionallyLoadAnalytics({
133
+ writeKey: 'key',
134
+ destinations: [],
135
+ destinationPreferences: {},
136
+ categoryPreferences: {},
137
+ isConsentRequired: true,
138
+ consentUpdate,
139
+ })
140
+ expect(reload).not.toHaveBeenCalled()
141
+ if (settles) finish()
142
+ else jest.advanceTimersByTime(500)
143
+ await Promise.resolve()
144
+ expect(reload).toHaveBeenCalledTimes(1)
145
+ finish()
146
+ jest.runAllTimers()
147
+ await Promise.resolve()
148
+ expect(reload).toHaveBeenCalledTimes(1)
149
+ } finally {
150
+ jest.useRealTimers()
151
+ }
152
+ },
153
+ )
154
+
116
155
  test('should allow the reload behvaiour to be disabled', () => {
117
156
  const reload = sinon.spy()
118
157
  wd.htevents.load = function load() {
119
158
  this.initialized = true
120
159
  }
121
- wd.location = { reload }
160
+ Object.defineProperty(window, 'location', {
161
+ configurable: true,
162
+ value: { reload },
163
+ })
122
164
  const writeKey = '123'
123
165
  const destinations = [{ id: 'Amplitude' } as Destination]
124
166
  const destinationPreferences = {
125
- Amplitude: true
167
+ Amplitude: true,
126
168
  }
127
169
 
128
170
  conditionallyLoadAnalytics({
@@ -130,7 +172,7 @@ describe('analytics', () => {
130
172
  destinations,
131
173
  destinationPreferences,
132
174
  isConsentRequired: true,
133
- categoryPreferences: {}
175
+ categoryPreferences: {},
134
176
  })
135
177
  conditionallyLoadAnalytics({
136
178
  writeKey,
@@ -138,7 +180,7 @@ describe('analytics', () => {
138
180
  destinationPreferences,
139
181
  isConsentRequired: true,
140
182
  shouldReload: false,
141
- categoryPreferences: {}
183
+ categoryPreferences: {},
142
184
  })
143
185
 
144
186
  expect(reload.calledOnce).toBe(false)
@@ -156,7 +198,7 @@ describe('analytics', () => {
156
198
  destinations,
157
199
  destinationPreferences,
158
200
  isConsentRequired: false,
159
- categoryPreferences: {}
201
+ categoryPreferences: {},
160
202
  })
161
203
 
162
204
  expect(hteventsLoad.calledOnce).toBe(true)
@@ -170,7 +212,7 @@ describe('analytics', () => {
170
212
  const writeKey = '123'
171
213
  const destinations = [{ id: 'Amplitude' } as Destination]
172
214
  const destinationPreferences = {
173
- Amplitude: true
215
+ Amplitude: true,
174
216
  }
175
217
 
176
218
  conditionallyLoadAnalytics({
@@ -178,7 +220,7 @@ describe('analytics', () => {
178
220
  destinations,
179
221
  destinationPreferences,
180
222
  isConsentRequired: false,
181
- categoryPreferences: {}
223
+ categoryPreferences: {},
182
224
  })
183
225
 
184
226
  expect(hteventsLoad.calledOnce).toBe(true)
@@ -187,8 +229,8 @@ describe('analytics', () => {
187
229
  integrations: {
188
230
  All: false,
189
231
  Amplitude: true,
190
- 'Hightouch.io': true
191
- }
232
+ 'Hightouch.io': true,
233
+ },
192
234
  })
193
235
  })
194
236
 
@@ -198,10 +240,10 @@ describe('analytics', () => {
198
240
  const writeKey = '123'
199
241
  const destinations = [
200
242
  { id: 'Amplitude' } as Destination,
201
- { id: 'Google Analytics' } as Destination
243
+ { id: 'Google Analytics' } as Destination,
202
244
  ]
203
245
  const destinationPreferences = {
204
- Amplitude: true
246
+ Amplitude: true,
205
247
  }
206
248
 
207
249
  conditionallyLoadAnalytics({
@@ -211,7 +253,7 @@ describe('analytics', () => {
211
253
  isConsentRequired: false,
212
254
  shouldReload: true,
213
255
  defaultDestinationBehavior: 'disable',
214
- categoryPreferences: {}
256
+ categoryPreferences: {},
215
257
  })
216
258
 
217
259
  expect(hteventsLoad.args[0][1]).toMatchObject({
@@ -219,8 +261,8 @@ describe('analytics', () => {
219
261
  All: false,
220
262
  Amplitude: true,
221
263
  'Google Analytics': false,
222
- 'Hightouch.io': true
223
- }
264
+ 'Hightouch.io': true,
265
+ },
224
266
  })
225
267
  })
226
268
 
@@ -230,10 +272,10 @@ describe('analytics', () => {
230
272
  const writeKey = '123'
231
273
  const destinations = [
232
274
  { id: 'Amplitude' } as Destination,
233
- { id: 'Google Analytics' } as Destination
275
+ { id: 'Google Analytics' } as Destination,
234
276
  ]
235
277
  const destinationPreferences = {
236
- Amplitude: true
278
+ Amplitude: true,
237
279
  }
238
280
 
239
281
  conditionallyLoadAnalytics({
@@ -243,7 +285,7 @@ describe('analytics', () => {
243
285
  isConsentRequired: false,
244
286
  shouldReload: true,
245
287
  defaultDestinationBehavior: 'enable',
246
- categoryPreferences: {}
288
+ categoryPreferences: {},
247
289
  })
248
290
 
249
291
  expect(hteventsLoad.args[0][1]).toMatchObject({
@@ -251,8 +293,8 @@ describe('analytics', () => {
251
293
  All: false,
252
294
  Amplitude: true,
253
295
  'Google Analytics': true,
254
- 'Hightouch.io': true
255
- }
296
+ 'Hightouch.io': true,
297
+ },
256
298
  })
257
299
  })
258
300
 
@@ -262,7 +304,7 @@ describe('analytics', () => {
262
304
  const writeKey = '123'
263
305
  const destinations = [{ id: 'Amplitude' } as Destination]
264
306
  const destinationPreferences = {
265
- Amplitude: true
307
+ Amplitude: true,
266
308
  }
267
309
 
268
310
  conditionallyLoadAnalytics({
@@ -271,7 +313,7 @@ describe('analytics', () => {
271
313
  destinationPreferences,
272
314
  isConsentRequired: false,
273
315
  categoryPreferences: {},
274
- devMode: true
316
+ devMode: true,
275
317
  })
276
318
 
277
319
  expect(hteventsLoad.calledOnce).toBe(false)
@@ -13,25 +13,25 @@ describe('ConsentManagerBuilder', () => {
13
13
 
14
14
  test.todo('doesn՚t load events.js when consent is required')
15
15
 
16
- test.skip('provides a list of enabled destinations', done => {
16
+ test.skip('provides a list of enabled destinations', (done) => {
17
17
  nock('https://cdn.hightouch-events.com')
18
18
  .get('/v1/projects/123/integrations')
19
19
  .reply(200, [
20
20
  {
21
21
  name: 'Google Analytics',
22
- creationName: 'Google Analytics'
22
+ creationName: 'Google Analytics',
23
23
  },
24
24
  {
25
25
  name: 'Amplitude',
26
- creationName: 'Amplitude'
27
- }
26
+ creationName: 'Amplitude',
27
+ },
28
28
  ])
29
29
  .get('/v1/projects/abc/integrations')
30
30
  .reply(200, [
31
31
  {
32
32
  name: 'FullStory',
33
- creationName: 'FullStory'
34
- }
33
+ creationName: 'FullStory',
34
+ },
35
35
  ])
36
36
 
37
37
  shallow(
@@ -40,24 +40,24 @@ describe('ConsentManagerBuilder', () => {
40
40
  expect(destinations).toMatchObject([
41
41
  {
42
42
  id: 'Amplitude',
43
- name: 'Amplitude'
43
+ name: 'Amplitude',
44
44
  },
45
45
  {
46
46
  id: 'FullStory',
47
- name: 'FullStory'
47
+ name: 'FullStory',
48
48
  },
49
49
  {
50
50
  id: 'Google Analytics',
51
- name: 'Google Analytics'
52
- }
51
+ name: 'Google Analytics',
52
+ },
53
53
  ])
54
54
  done()
55
55
  }}
56
- </ConsentManagerBuilder>
56
+ </ConsentManagerBuilder>,
57
57
  )
58
58
  })
59
59
 
60
- test.skip('provides a list of newly added destinations', done => {
60
+ test.skip('provides a list of newly added destinations', (done) => {
61
61
  document.cookie =
62
62
  'ht-cm-preferences={%22version%22:1%2C%22destinations%22:{%22Amplitude%22:true}}'
63
63
  window.htevents = { load() {}, track() {}, addSourceMiddleware() {} }
@@ -67,12 +67,12 @@ describe('ConsentManagerBuilder', () => {
67
67
  .reply(200, [
68
68
  {
69
69
  name: 'Google Analytics',
70
- creationName: 'Google Analytics'
70
+ creationName: 'Google Analytics',
71
71
  },
72
72
  {
73
73
  name: 'Amplitude',
74
- creationName: 'Amplitude'
75
- }
74
+ creationName: 'Amplitude',
75
+ },
76
76
  ])
77
77
 
78
78
  shallow(
@@ -81,16 +81,16 @@ describe('ConsentManagerBuilder', () => {
81
81
  expect(newDestinations).toMatchObject([
82
82
  {
83
83
  name: 'Google Analytics',
84
- id: 'Google Analytics'
85
- }
84
+ id: 'Google Analytics',
85
+ },
86
86
  ])
87
87
  done()
88
88
  }}
89
- </ConsentManagerBuilder>
89
+ </ConsentManagerBuilder>,
90
90
  )
91
91
  })
92
92
 
93
- test.skip('loads events.js with the user՚s preferences', done => {
93
+ test.skip('loads events.js with the user՚s preferences', (done) => {
94
94
  const hteventsLoad = sinon.spy()
95
95
  document.cookie =
96
96
  'ht-cm-preferences={%22version%22:1%2C%22destinations%22:{%22Amplitude%22:true}}'
@@ -102,8 +102,8 @@ describe('ConsentManagerBuilder', () => {
102
102
  .reply(200, [
103
103
  {
104
104
  name: 'Amplitude',
105
- creationName: 'Amplitude'
106
- }
105
+ creationName: 'Amplitude',
106
+ },
107
107
  ])
108
108
 
109
109
  shallow(
@@ -114,16 +114,16 @@ describe('ConsentManagerBuilder', () => {
114
114
  expect(hteventsLoad.args[0][1]).toMatchObject({
115
115
  integrations: {
116
116
  All: false,
117
- Amplitude: true
118
- }
117
+ Amplitude: true,
118
+ },
119
119
  })
120
120
  done()
121
121
  }}
122
- </ConsentManagerBuilder>
122
+ </ConsentManagerBuilder>,
123
123
  )
124
124
  })
125
125
 
126
- test.skip('provides an object containing the WIP preferences', done => {
126
+ test.skip('provides an object containing the WIP preferences', (done) => {
127
127
  document.cookie =
128
128
  'ht-cm-preferences={%22version%22:1%2C%22destinations%22:{%22Amplitude%22:true}}'
129
129
  window.htevents = { load() {}, track() {}, addSourceMiddleware() {} }
@@ -133,30 +133,30 @@ describe('ConsentManagerBuilder', () => {
133
133
  .reply(200, [
134
134
  {
135
135
  name: 'Amplitude',
136
- creationName: 'Amplitude'
137
- }
136
+ creationName: 'Amplitude',
137
+ },
138
138
  ])
139
139
 
140
140
  shallow(
141
141
  <ConsentManagerBuilder writeKey="123">
142
142
  {({ preferences }) => {
143
143
  expect(preferences).toMatchObject({
144
- Amplitude: true
144
+ Amplitude: true,
145
145
  })
146
146
  done()
147
147
  }}
148
- </ConsentManagerBuilder>
148
+ </ConsentManagerBuilder>,
149
149
  )
150
150
  })
151
151
 
152
- test.skip('does not imply consent on interacation', done => {
152
+ test.skip('does not imply consent on interacation', (done) => {
153
153
  nock('https://cdn.hightouch-events.com')
154
154
  .get('/v1/projects/123/integrations')
155
155
  .reply(200, [
156
156
  {
157
157
  name: 'Amplitude',
158
- creationName: 'Amplitude'
159
- }
158
+ creationName: 'Amplitude',
159
+ },
160
160
  ])
161
161
 
162
162
  shallow(
@@ -165,17 +165,17 @@ describe('ConsentManagerBuilder', () => {
165
165
  expect(preferences).toMatchObject({})
166
166
  done()
167
167
  }}
168
- </ConsentManagerBuilder>
168
+ </ConsentManagerBuilder>,
169
169
  )
170
170
  })
171
171
 
172
- test.skip('if defaultDestinationBehavior is set to imply and category is set to true, loads new destination', done => {
172
+ test.skip('if defaultDestinationBehavior is set to imply and category is set to true, loads new destination', (done) => {
173
173
  document.cookie =
174
174
  'ht-cm-preferences={%22version%22:1%2C%22destinations%22:{%22Amplitude%22:true}%2C%22custom%22:{%22advertising%22:false%2C%22marketingAndAnalytics%22:true%2C%22functional%22:true}}'
175
175
  window.htevents = {
176
176
  load() {},
177
177
  track() {},
178
- addSourceMiddleware() {}
178
+ addSourceMiddleware() {},
179
179
  }
180
180
 
181
181
  nock('https://cdn.hightouch-events.com')
@@ -183,12 +183,12 @@ describe('ConsentManagerBuilder', () => {
183
183
  .reply(200, [
184
184
  {
185
185
  name: 'Google Analytics',
186
- creationName: 'Google Analytics'
186
+ creationName: 'Google Analytics',
187
187
  },
188
188
  {
189
189
  name: 'Amplitude',
190
- creationName: 'Amplitude'
191
- }
190
+ creationName: 'Amplitude',
191
+ },
192
192
  ])
193
193
 
194
194
  shallow(
@@ -213,7 +213,7 @@ describe('ConsentManagerBuilder', () => {
213
213
  for (const destination of destinations) {
214
214
  // Mark advertising destinations
215
215
  if (
216
- ADVERTISING_CATEGORIES.find(c => c === destination.category) &&
216
+ ADVERTISING_CATEGORIES.find((c) => c === destination.category) &&
217
217
  destinationPreferences[destination.id] !== false
218
218
  ) {
219
219
  destinationPreferences[destination.id] = customPrefs.advertising
@@ -221,7 +221,7 @@ describe('ConsentManagerBuilder', () => {
221
221
 
222
222
  // Mark function destinations
223
223
  if (
224
- FUNCTIONAL_CATEGORIES.find(c => c === destination.category) &&
224
+ FUNCTIONAL_CATEGORIES.find((c) => c === destination.category) &&
225
225
  destinationPreferences[destination.id] !== false
226
226
  ) {
227
227
  destinationPreferences[destination.id] = customPrefs.functional
@@ -239,21 +239,21 @@ describe('ConsentManagerBuilder', () => {
239
239
  {({ destinationPreferences }) => {
240
240
  expect(destinationPreferences).toMatchObject({
241
241
  Amplitude: true,
242
- 'Google Analytics': true
242
+ 'Google Analytics': true,
243
243
  })
244
244
  done()
245
245
  }}
246
- </ConsentManagerBuilder>
246
+ </ConsentManagerBuilder>,
247
247
  )
248
248
  })
249
249
 
250
- test.skip('if defaultDestinationBehavior is set to imply and category is set to false, does not load new destination', done => {
250
+ test.skip('if defaultDestinationBehavior is set to imply and category is set to false, does not load new destination', (done) => {
251
251
  document.cookie =
252
252
  'ht-cm-preferences={%22version%22:1%2C%22destinations%22:{%22Amplitude%22:true}%2C%22custom%22:{%22advertising%22:false%2C%22marketingAndAnalytics%22:false%2C%22functional%22:true}}'
253
253
  window.htevents = {
254
254
  load() {},
255
255
  track() {},
256
- addSourceMiddleware() {}
256
+ addSourceMiddleware() {},
257
257
  }
258
258
 
259
259
  nock('https://cdn.hightouch-events.com')
@@ -261,12 +261,12 @@ describe('ConsentManagerBuilder', () => {
261
261
  .reply(200, [
262
262
  {
263
263
  name: 'Google Analytics',
264
- creationName: 'Google Analytics'
264
+ creationName: 'Google Analytics',
265
265
  },
266
266
  {
267
267
  name: 'Amplitude',
268
- creationName: 'Amplitude'
269
- }
268
+ creationName: 'Amplitude',
269
+ },
270
270
  ])
271
271
 
272
272
  shallow(
@@ -292,7 +292,7 @@ describe('ConsentManagerBuilder', () => {
292
292
  for (const destination of destinations) {
293
293
  // Mark advertising destinations
294
294
  if (
295
- ADVERTISING_CATEGORIES.find(c => c === destination.category) &&
295
+ ADVERTISING_CATEGORIES.find((c) => c === destination.category) &&
296
296
  destinationPreferences[destination.id] !== false
297
297
  ) {
298
298
  destinationPreferences[destination.id] = customPrefs.advertising
@@ -300,7 +300,7 @@ describe('ConsentManagerBuilder', () => {
300
300
 
301
301
  // Mark function destinations
302
302
  if (
303
- FUNCTIONAL_CATEGORIES.find(c => c === destination.category) &&
303
+ FUNCTIONAL_CATEGORIES.find((c) => c === destination.category) &&
304
304
  destinationPreferences[destination.id] !== false
305
305
  ) {
306
306
  destinationPreferences[destination.id] = customPrefs.functional
@@ -318,64 +318,21 @@ describe('ConsentManagerBuilder', () => {
318
318
  {({ destinationPreferences }) => {
319
319
  expect(destinationPreferences).toMatchObject({
320
320
  Amplitude: false,
321
- 'Google Analytics': false
321
+ 'Google Analytics': false,
322
322
  })
323
323
  done()
324
324
  }}
325
- </ConsentManagerBuilder>
325
+ </ConsentManagerBuilder>,
326
326
  )
327
327
  })
328
328
 
329
- test.skip('a different cdn is used when cdnHost is set', done => {
330
- nock('https://foo.bar.com')
331
- .get('/v1/projects/123/integrations')
332
- .reply(200, [
333
- {
334
- name: 'Google Analytics',
335
- creationName: 'Google Analytics'
336
- },
337
- {
338
- name: 'Amplitude',
339
- creationName: 'Amplitude'
340
- }
341
- ])
342
- .get('/v1/projects/abc/integrations')
343
- .reply(200, [
344
- {
345
- name: 'FullStory',
346
- creationName: 'FullStory'
347
- }
348
- ])
349
-
350
- shallow(
351
- <ConsentManagerBuilder writeKey="123" cdnHost="foo.bar.com">
352
- {({ destinations }) => {
353
- expect(destinations).toMatchObject([
354
- {
355
- id: 'Amplitude',
356
- name: 'Amplitude'
357
- },
358
- {
359
- id: 'FullStory',
360
- name: 'FullStory'
361
- },
362
- {
363
- id: 'Google Analytics',
364
- name: 'Google Analytics'
365
- }
366
- ])
367
- done()
368
- }}
369
- </ConsentManagerBuilder>
370
- )
371
- })
372
329
  test.todo('loads events.js normally when consent isn՚t required')
373
330
  test.todo('still applies preferences when consent isn՚t required')
374
331
  test.todo('provides a setPreferences() function for setting the preferences')
375
332
  test.todo('setPreferences() function can be passed a boolean to set all preferences')
376
333
  test.todo('provides a resetPreferences() function for resetting the preferences')
377
334
  test.todo(
378
- 'provides a saveConsent() function for persisting the preferences and loading events.js'
335
+ 'provides a saveConsent() function for persisting the preferences and loading events.js',
379
336
  )
380
337
  test.todo('saveConsent() can be passed additional preferences to persist')
381
338
  test.todo('saveConsent() can be passed a boolean to set all preferences')