@planningcenter/chat-react-native 4.8.0-qa-staging.8 → 4.8.0-qa-staging.10

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 (44) hide show
  1. package/build/contexts/session_context.d.ts +0 -1
  2. package/build/contexts/session_context.d.ts.map +1 -1
  3. package/build/contexts/session_context.js.map +1 -1
  4. package/build/utils/theme.js +20 -21
  5. package/build/utils/theme.js.map +1 -1
  6. package/package.json +3 -3
  7. package/src/__tests__/contexts/session_context.tsx +19 -39
  8. package/src/__tests__/hooks/useTheme.tsx +0 -7
  9. package/src/__tests__/hooks/use_async_storage.test.tsx +1 -87
  10. package/src/__tests__/hooks/use_attachment_uploader.test.tsx +0 -11
  11. package/src/__tests__/hooks/use_font_scale.test.ts +0 -25
  12. package/src/__tests__/utils/cache/page_mutations.ts +3 -68
  13. package/src/__tests__/utils/client.ts +6 -15
  14. package/src/__tests__/utils/native_adapters/configuration.ts +15 -50
  15. package/src/__tests__/utils/parse_simple_markdown.ts +0 -6
  16. package/src/__tests__/utils/session.ts +0 -11
  17. package/src/__tests__/utils/theme.ts +0 -17
  18. package/src/components/conversations/__tests__/conversations.test.tsx +4 -1
  19. package/src/components/display/__tests__/filter_dropdown.test.tsx +1 -19
  20. package/src/components/display/__tests__/icon_tile.test.tsx +24 -7
  21. package/src/components/page/__tests__/component_error_boundary.test.tsx +0 -12
  22. package/src/contexts/session_context.tsx +0 -1
  23. package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +0 -35
  24. package/src/screens/__tests__/conversation_details_screen.test.tsx +0 -19
  25. package/src/screens/avatar_picker/__tests__/avatar_picker_state.test.ts +0 -14
  26. package/src/screens/conversations/__tests__/conversations_screen.test.tsx +0 -6
  27. package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +0 -8
  28. package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +0 -10
  29. package/src/screens/search/components/__tests__/search_results_list.test.tsx +1 -0
  30. package/src/utils/__tests__/attachment_kind.test.ts +0 -4
  31. package/src/utils/__tests__/convert_attachments_for_create.test.ts +0 -28
  32. package/src/utils/__tests__/is_input_editable.test.ts +1 -2
  33. package/src/utils/__tests__/message_text.test.ts +0 -5
  34. package/src/utils/__tests__/session_manager.test.ts +0 -83
  35. package/src/utils/__tests__/sha_256.test.ts +0 -34
  36. package/src/utils/__tests__/uri.test.ts +51 -0
  37. package/src/utils/theme.ts +20 -21
  38. package/src/__tests__/event-polyfill.test.ts +0 -313
  39. package/src/__tests__/index.tsx +0 -5
  40. package/src/__tests__/jest.ts +0 -11
  41. package/src/__tests__/utils/uri.ts +0 -65
  42. package/src/components/display/__tests__/version_footer.test.tsx +0 -48
  43. package/src/screens/search/components/__tests__/search_blank_states.test.tsx +0 -20
  44. package/src/utils/__tests__/membership_sync_info_text.test.ts +0 -15
@@ -35,30 +35,9 @@ describe('SessionManager', () => {
35
35
  expect(manager.sessions).toEqual({})
36
36
  expect(manager.currentSession.isAuthenticated).toBe(false)
37
37
  })
38
-
39
- it('should return a default SessionManager when given empty string', () => {
40
- const manager = SessionManager.hydrate('')
41
-
42
- expect(manager.currentSessionId).toBe(UNAUTHENTICATED_SESSION_ID)
43
- expect(manager.sessions).toEqual({})
44
- })
45
38
  })
46
39
 
47
40
  describe('currentSession', () => {
48
- it('should return the current session when it exists', () => {
49
- const session = new Session({ token: createToken('token-12345678') })
50
- const managerString = JSON.stringify({
51
- sessions: { '12345678': session.toString() },
52
- currentSessionId: '12345678',
53
- })
54
- const manager = SessionManager.hydrate(managerString)
55
-
56
- const currentSession = manager.currentSession
57
-
58
- expect(currentSession.isAuthenticated).toBe(true)
59
- expect(currentSession.token?.access_token).toBe('token-12345678')
60
- })
61
-
62
41
  it('should return an unauthenticated session when currentSessionId does not exist', () => {
63
42
  const managerString = JSON.stringify({
64
43
  sessions: {},
@@ -71,17 +50,6 @@ describe('SessionManager', () => {
71
50
  expect(currentSession.isAuthenticated).toBe(false)
72
51
  expect(currentSession.id).toBe(UNAUTHENTICATED_SESSION_ID)
73
52
  })
74
-
75
- it('should return an unauthenticated session when currentSessionId is unauthenticated', () => {
76
- const manager = SessionManager.hydrate(
77
- JSON.stringify({ sessions: {}, currentSessionId: UNAUTHENTICATED_SESSION_ID })
78
- )
79
-
80
- const currentSession = manager.currentSession
81
-
82
- expect(currentSession.isAuthenticated).toBe(false)
83
- expect(currentSession.id).toBe(UNAUTHENTICATED_SESSION_ID)
84
- })
85
53
  })
86
54
 
87
55
  describe('setEnv', () => {
@@ -153,17 +121,6 @@ describe('SessionManager', () => {
153
121
  expect(manager.currentSession.env).toBe('staging')
154
122
  expect(manager.currentSessionId).toBe('12345678')
155
123
  })
156
-
157
- it('should update currentSessionId to match the session ID', () => {
158
- const manager = SessionManager.hydrate(
159
- JSON.stringify({ sessions: {}, currentSessionId: UNAUTHENTICATED_SESSION_ID })
160
- )
161
- const session = new Session({ token: createToken('token-11111111') })
162
-
163
- manager.upsertSession(session)
164
-
165
- expect(manager.currentSessionId).toBe('11111111')
166
- })
167
124
  })
168
125
 
169
126
  describe('removeSession', () => {
@@ -216,17 +173,6 @@ describe('SessionManager', () => {
216
173
  expect(manager.currentSessionId).toBe('11111111')
217
174
  expect(manager.sessions).not.toHaveProperty('22222222')
218
175
  })
219
-
220
- it('should handle removing unauthenticated session gracefully', () => {
221
- const manager = SessionManager.hydrate(
222
- JSON.stringify({ sessions: {}, currentSessionId: UNAUTHENTICATED_SESSION_ID })
223
- )
224
-
225
- manager.removeSession(UNAUTHENTICATED_SESSION_ID)
226
-
227
- expect(manager.currentSessionId).toBe(UNAUTHENTICATED_SESSION_ID)
228
- expect(manager.sessions).not.toHaveProperty(UNAUTHENTICATED_SESSION_ID)
229
- })
230
176
  })
231
177
 
232
178
  describe('updateCurrentToken', () => {
@@ -244,20 +190,6 @@ describe('SessionManager', () => {
244
190
 
245
191
  expect(manager.currentSession.token?.access_token).toBe('token-22222222')
246
192
  expect(manager.currentSessionId).toBe('22222222')
247
- })
248
-
249
- it('should remove the old session when token changes', () => {
250
- const oldToken = createToken('token-11111111')
251
- const session = new Session({ token: oldToken })
252
- const managerString = JSON.stringify({
253
- sessions: { '11111111': session.toString() },
254
- currentSessionId: '11111111',
255
- })
256
- const manager = SessionManager.hydrate(managerString)
257
- const newToken = createToken('token-22222222')
258
-
259
- manager.updateCurrentToken(newToken)
260
-
261
193
  expect(manager.sessions).not.toHaveProperty('11111111')
262
194
  expect(manager.sessions).toHaveProperty('22222222')
263
195
  })
@@ -292,21 +224,6 @@ describe('SessionManager', () => {
292
224
  })
293
225
 
294
226
  describe('toString', () => {
295
- it('should serialize the manager to a JSON string', () => {
296
- const session = new Session({ token: createToken('token-12345678') })
297
- const managerString = JSON.stringify({
298
- sessions: { '12345678': session.toString() },
299
- currentSessionId: '12345678',
300
- })
301
- const manager = SessionManager.hydrate(managerString)
302
-
303
- const serialized = manager.toString()
304
- const parsed = JSON.parse(serialized)
305
-
306
- expect(parsed.currentSessionId).toBe('12345678')
307
- expect(parsed.sessions).toHaveProperty('12345678')
308
- })
309
-
310
227
  it('should produce a string that can be hydrated back to the same state', () => {
311
228
  const session1 = new Session({ token: createToken('token-11111111') })
312
229
  const session2 = new Session({ token: createToken('token-22222222') })
@@ -11,11 +11,6 @@ describe('SHA256', () => {
11
11
  expect(hash).toBe('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad')
12
12
  })
13
13
 
14
- it('computes correct hash for "The quick brown fox jumps over the lazy dog"', () => {
15
- const hash = SHA256('The quick brown fox jumps over the lazy dog').toString(enc.Hex)
16
- expect(hash).toBe('d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')
17
- })
18
-
19
14
  it('computes correct hash for longer message', () => {
20
15
  const message = 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'
21
16
  const hash = SHA256(message).toString(enc.Hex)
@@ -34,37 +29,8 @@ describe('SHA256', () => {
34
29
  expect(hash).toBe('c15ee319b97bfd23fa98590baf0b47d1f7b7b81f9e5bf99d8275867e2e4a32a2')
35
30
  })
36
31
 
37
- it('computes correct hash for JSON payload', () => {
38
- const payload = JSON.stringify({ events: [{ name: 'test', meta: { foo: 'bar' } }] })
39
- const hash = SHA256(payload).toString(enc.Hex)
40
- expect(hash).toBe('5e4043aadad336890b9795ee03675a9de1a6abbc4e84f9f95daaffb21569312e')
41
- })
42
-
43
32
  it('toString without encoding parameter defaults to hex', () => {
44
33
  const hash = SHA256('abc').toString()
45
34
  expect(hash).toBe('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad')
46
35
  })
47
-
48
- it('produces consistent results for the same input', () => {
49
- const input = 'test message'
50
- const hash1 = SHA256(input).toString(enc.Hex)
51
- const hash2 = SHA256(input).toString(enc.Hex)
52
- expect(hash1).toBe(hash2)
53
- })
54
-
55
- it('produces different hashes for different inputs', () => {
56
- const hash1 = SHA256('message 1').toString(enc.Hex)
57
- const hash2 = SHA256('message 2').toString(enc.Hex)
58
- expect(hash1).not.toBe(hash2)
59
- })
60
-
61
- it('handles strings with special characters', () => {
62
- const hash = SHA256('!@#$%^&*()_+-=[]{}|;:",.<>?/~`').toString(enc.Hex)
63
- expect(hash).toBe('67764597efaadfd3a9d89032105c9fcde16c6f05d16214e42488af193abb280a')
64
- })
65
-
66
- it('handles strings with newlines and tabs', () => {
67
- const hash = SHA256('line1\nline2\tline3').toString(enc.Hex)
68
- expect(hash).toBe('450c0302bb6c2b9d81f81c8c868f7e96e3a35bc83751a08b7da09e77c4f13eec')
69
- })
70
36
  })
@@ -24,3 +24,54 @@ describe('on a Protonova environment', () => {
24
24
  )
25
25
  })
26
26
  })
27
+
28
+ describe('baseUrl', () => {
29
+ describe('planning center', () => {
30
+ it('should return the correct base URL for production', () => {
31
+ const uri = new Uri({
32
+ session: new Session({ env: 'production', type: 'OAuth' }),
33
+ })
34
+ expect(uri.baseUrl).toBe('https://api.planningcenteronline.com')
35
+ })
36
+
37
+ it('should return the correct base URL for staging', () => {
38
+ const uri = new Uri({
39
+ session: new Session({ env: 'staging', type: 'OAuth' }),
40
+ })
41
+ expect(uri.baseUrl).toBe('https://api-staging.planningcenteronline.com')
42
+ })
43
+
44
+ it('should return the correct base URL for development', () => {
45
+ const uri = new Uri({
46
+ session: new Session({ env: 'development', type: 'OAuth' }),
47
+ })
48
+ expect(uri.baseUrl).toBe('https://api.pco.test')
49
+ })
50
+ })
51
+
52
+ describe('church center', () => {
53
+ it('should return the correct base URL for production', () => {
54
+ const uri = new Uri({
55
+ session: new Session({ env: 'production', type: 'ChurchCenterOauth' }),
56
+ graph: 'churchcenter',
57
+ })
58
+ expect(uri.baseUrl).toBe('https://api.churchcenter.com')
59
+ })
60
+
61
+ it('should return the correct base URL for staging', () => {
62
+ const uri = new Uri({
63
+ session: new Session({ env: 'staging', type: 'ChurchCenterOauth' }),
64
+ graph: 'churchcenter',
65
+ })
66
+ expect(uri.baseUrl).toBe('https://api.staging.churchcenter.com')
67
+ })
68
+
69
+ it('should return the correct base URL for development', () => {
70
+ const uri = new Uri({
71
+ session: new Session({ env: 'development', type: 'ChurchCenterOauth' }),
72
+ graph: 'churchcenter',
73
+ })
74
+ expect(uri.baseUrl).toBe('https://api.churchcenter.test')
75
+ })
76
+ })
77
+ })
@@ -142,20 +142,20 @@ const colorsChatLight: ChatColors = {
142
142
  statusErrorText: tokens.textColorStatusError,
143
143
  statusErrorBorder: tokens.borderColorStatusError,
144
144
  statusErrorFill: tokens.fillColorStatusErrorSolid,
145
- statusInfoComposedIcon: tokens.iconColorStatusInfoPrimary,
146
- statusInfoComposedText: tokens.textColorStatusInfo,
145
+ statusInfoComposedIcon: tokens.textColorStatusInfo,
146
+ statusInfoComposedText: tokens.colorNeutral24,
147
147
  statusInfoComposedBackground: tokens.fillColorStatusInfoGhost,
148
- statusSuccessComposedIcon: tokens.iconColorStatusSuccessPrimary,
149
- statusSuccessComposedText: tokens.textColorStatusSuccess,
148
+ statusSuccessComposedIcon: tokens.textColorStatusSuccess,
149
+ statusSuccessComposedText: tokens.colorNeutral24,
150
150
  statusSuccessComposedBackground: tokens.fillColorStatusSuccessGhost,
151
- statusWarningComposedIcon: tokens.iconColorStatusWarningPrimary,
152
- statusWarningComposedText: tokens.textColorStatusWarning,
151
+ statusWarningComposedIcon: tokens.textColorStatusWarning,
152
+ statusWarningComposedText: tokens.colorNeutral24,
153
153
  statusWarningComposedBackground: tokens.fillColorStatusWarningGhost,
154
- statusErrorComposedIcon: tokens.iconColorStatusErrorPrimary,
155
- statusErrorComposedText: tokens.textColorStatusError,
154
+ statusErrorComposedIcon: tokens.textColorStatusError,
155
+ statusErrorComposedText: tokens.colorNeutral24,
156
156
  statusErrorComposedBackground: tokens.fillColorStatusErrorGhost,
157
- statusNeutralComposedIcon: tokens.iconColorStatusNeutralPrimary,
158
- statusNeutralComposedText: tokens.textColorStatusNeutral,
157
+ statusNeutralComposedIcon: tokens.textColorStatusNeutral,
158
+ statusNeutralComposedText: tokens.colorNeutral24,
159
159
  statusNeutralComposedBackground: tokens.fillColorStatusNeutralGhost,
160
160
  borderColorChip: tokens.colorNeutral88,
161
161
  fillColorChip: 'transparent',
@@ -189,21 +189,20 @@ const colorsChatDark: ChatColors = {
189
189
  statusErrorBorder: tokens.borderColorStatusErrorDark,
190
190
  statusErrorFill: tokens.fillColorStatusErrorSolidDark,
191
191
 
192
- // Note: CCA inverts composed status colors in dark mode
193
- statusInfoComposedIcon: tokens.iconColorStatusInfoPrimaryDark,
194
- statusInfoComposedText: tokens.textColorStatusInfoDark,
192
+ statusInfoComposedIcon: tokens.textColorStatusInfoDark,
193
+ statusInfoComposedText: tokens.colorNeutral88,
195
194
  statusInfoComposedBackground: tokens.fillColorStatusInfoGhostDark,
196
- statusSuccessComposedIcon: tokens.iconColorStatusSuccessPrimaryDark,
197
- statusSuccessComposedText: tokens.textColorStatusSuccessDark,
195
+ statusSuccessComposedIcon: tokens.textColorStatusSuccessDark,
196
+ statusSuccessComposedText: tokens.colorNeutral88,
198
197
  statusSuccessComposedBackground: tokens.fillColorStatusSuccessGhostDark,
199
- statusWarningComposedIcon: tokens.iconColorStatusWarningPrimaryDark,
200
- statusWarningComposedText: tokens.textColorStatusWarningDark,
198
+ statusWarningComposedIcon: tokens.textColorStatusWarningDark,
199
+ statusWarningComposedText: tokens.colorNeutral88,
201
200
  statusWarningComposedBackground: tokens.fillColorStatusWarningGhostDark,
202
- statusErrorComposedIcon: tokens.iconColorStatusErrorPrimaryDark,
203
- statusErrorComposedText: tokens.textColorStatusErrorDark,
201
+ statusErrorComposedIcon: tokens.textColorStatusErrorDark,
202
+ statusErrorComposedText: tokens.colorNeutral88,
204
203
  statusErrorComposedBackground: tokens.fillColorStatusErrorGhostDark,
205
- statusNeutralComposedIcon: tokens.iconColorStatusNeutralPrimaryDark,
206
- statusNeutralComposedText: tokens.textColorStatusNeutralDark,
204
+ statusNeutralComposedIcon: tokens.textColorStatusNeutralDark,
205
+ statusNeutralComposedText: tokens.colorNeutral88,
207
206
  statusNeutralComposedBackground: tokens.fillColorStatusNeutralGhostDark,
208
207
  borderColorChip: tokens.colorNeutral24,
209
208
  fillColorChip: 'transparent',
@@ -1,313 +0,0 @@
1
- /**
2
- * Tests for Event/CustomEvent/EventTarget polyfills
3
- */
4
-
5
- import { CustomEvent } from '../polyfills/events/CustomEvent'
6
- // Set up global polyfill for tests
7
- import Event from '../polyfills/events/Event'
8
- import EventTarget from '../polyfills/events/EventTarget'
9
- ;(global as any).Event = Event
10
- ;(global as any).CustomEvent = CustomEvent
11
-
12
- describe('Event Polyfill', () => {
13
- describe('Event', () => {
14
- it('should create a basic event', () => {
15
- const event = new Event('test')
16
- expect(event.type).toBe('test')
17
- expect(event.bubbles).toBe(false)
18
- expect(event.cancelable).toBe(false)
19
- expect(event.composed).toBe(false)
20
- expect(event.defaultPrevented).toBe(false)
21
- expect(event.isTrusted).toBe(false)
22
- expect(event.eventPhase).toBe(Event.NONE)
23
- expect(typeof event.timeStamp).toBe('number')
24
- })
25
-
26
- it('should create an event with options', () => {
27
- const event = new Event('test', {
28
- bubbles: true,
29
- cancelable: true,
30
- composed: true,
31
- })
32
- expect(event.bubbles).toBe(true)
33
- expect(event.cancelable).toBe(true)
34
- expect(event.composed).toBe(true)
35
- })
36
-
37
- it('should have correct phase constants', () => {
38
- expect(Event.NONE).toBe(0)
39
- expect(Event.CAPTURING_PHASE).toBe(1)
40
- expect(Event.AT_TARGET).toBe(2)
41
- expect(Event.BUBBLING_PHASE).toBe(3)
42
- })
43
-
44
- it('should prevent default when cancelable', () => {
45
- const event = new Event('test', { cancelable: true })
46
- expect(event.defaultPrevented).toBe(false)
47
- event.preventDefault()
48
- expect(event.defaultPrevented).toBe(true)
49
- })
50
-
51
- it('should not prevent default when not cancelable', () => {
52
- const event = new Event('test', { cancelable: false })
53
- event.preventDefault()
54
- expect(event.defaultPrevented).toBe(false)
55
- })
56
-
57
- it('should support stopPropagation', () => {
58
- const event = new Event('test')
59
- // No error thrown - internal flags are set
60
- event.stopPropagation()
61
- event.stopImmediatePropagation()
62
- })
63
- })
64
-
65
- describe('CustomEvent', () => {
66
- it('should create a custom event with detail', () => {
67
- const detail = { foo: 'bar', count: 42 }
68
- const event = new CustomEvent('custom', { detail })
69
- expect(event.type).toBe('custom')
70
- expect(event.detail).toEqual(detail)
71
- })
72
-
73
- it('should inherit from Event', () => {
74
- const event = new CustomEvent('custom', {
75
- bubbles: true,
76
- cancelable: true,
77
- detail: 'test',
78
- })
79
- expect(event instanceof Event).toBe(true)
80
- expect(event.bubbles).toBe(true)
81
- expect(event.cancelable).toBe(true)
82
- })
83
-
84
- it('should handle undefined detail', () => {
85
- const event = new CustomEvent('custom')
86
- expect(event.detail).toBeUndefined()
87
- })
88
- })
89
-
90
- describe('EventTarget', () => {
91
- let target: EventTarget
92
-
93
- beforeEach(() => {
94
- target = new EventTarget()
95
- })
96
-
97
- it('should add and remove event listeners', () => {
98
- const listener = jest.fn()
99
- target.addEventListener('test', listener)
100
-
101
- const event = new Event('test')
102
- const result = target.dispatchEvent(event)
103
-
104
- expect(listener).toHaveBeenCalledWith(event)
105
- expect(listener).toHaveBeenCalledTimes(1)
106
- expect(result).toBe(true) // not prevented
107
-
108
- target.removeEventListener('test', listener)
109
- target.dispatchEvent(new Event('test'))
110
- expect(listener).toHaveBeenCalledTimes(1) // not called again
111
- })
112
-
113
- it('should handle multiple listeners for the same event', () => {
114
- const listener1 = jest.fn()
115
- const listener2 = jest.fn()
116
-
117
- target.addEventListener('test', listener1)
118
- target.addEventListener('test', listener2)
119
-
120
- target.dispatchEvent(new Event('test'))
121
-
122
- expect(listener1).toHaveBeenCalledTimes(1)
123
- expect(listener2).toHaveBeenCalledTimes(1)
124
- })
125
-
126
- it('should handle once option', () => {
127
- const listener = jest.fn()
128
- target.addEventListener('test', listener, { once: true })
129
-
130
- target.dispatchEvent(new Event('test'))
131
- target.dispatchEvent(new Event('test'))
132
-
133
- expect(listener).toHaveBeenCalledTimes(1)
134
- })
135
-
136
- it('should handle capture option', () => {
137
- const listener = jest.fn()
138
- target.addEventListener('test', listener, { capture: true })
139
-
140
- target.dispatchEvent(new Event('test'))
141
- expect(listener).toHaveBeenCalledTimes(1)
142
-
143
- target.removeEventListener('test', listener, { capture: true })
144
- target.dispatchEvent(new Event('test'))
145
- expect(listener).toHaveBeenCalledTimes(1)
146
- })
147
-
148
- it('should handle passive option', () => {
149
- const listener = jest.fn()
150
- target.addEventListener('test', listener, { passive: true })
151
-
152
- target.dispatchEvent(new Event('test'))
153
- expect(listener).toHaveBeenCalledTimes(1)
154
- })
155
-
156
- it('should handle object listeners with handleEvent', () => {
157
- const listener = {
158
- handleEvent: jest.fn(),
159
- }
160
-
161
- target.addEventListener('test', listener)
162
- target.dispatchEvent(new Event('test'))
163
-
164
- expect(listener.handleEvent).toHaveBeenCalledTimes(1)
165
- })
166
-
167
- it('should return false when event is prevented', () => {
168
- const listener = (event: Event) => {
169
- event.preventDefault()
170
- }
171
-
172
- target.addEventListener('test', listener)
173
- const event = new Event('test', { cancelable: true })
174
- const result = target.dispatchEvent(event)
175
-
176
- expect(result).toBe(false)
177
- expect(event.defaultPrevented).toBe(true)
178
- })
179
-
180
- it('should set event properties during dispatch', () => {
181
- let capturedEvent: Event | null = null
182
-
183
- const listener = (event: Event) => {
184
- capturedEvent = event
185
- expect(event.target).toBe(target)
186
- expect(event.currentTarget).toBe(target)
187
- expect(event.eventPhase).toBe(Event.AT_TARGET)
188
- }
189
-
190
- target.addEventListener('test', listener)
191
- target.dispatchEvent(new Event('test'))
192
-
193
- expect(capturedEvent).not.toBeNull()
194
- // After dispatch, these should be reset
195
- expect(capturedEvent!.currentTarget).toBeNull()
196
- expect(capturedEvent!.eventPhase).toBe(Event.NONE)
197
- })
198
-
199
- it('should handle bubbling events', () => {
200
- const listener = jest.fn()
201
- target.addEventListener('test', listener)
202
-
203
- const bubblingEvent = new Event('test', { bubbles: true })
204
- target.dispatchEvent(bubblingEvent)
205
-
206
- expect(listener).toHaveBeenCalledWith(bubblingEvent)
207
- })
208
-
209
- it('should handle error in listener gracefully', () => {
210
- const errorListener = () => {
211
- throw new Error('Test error')
212
- }
213
- const normalListener = jest.fn()
214
-
215
- // Mock console.error to avoid test output noise
216
- const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
217
-
218
- target.addEventListener('test', errorListener)
219
- target.addEventListener('test', normalListener)
220
-
221
- target.dispatchEvent(new Event('test'))
222
-
223
- expect(normalListener).toHaveBeenCalledTimes(1)
224
- expect(consoleErrorSpy).toHaveBeenCalled()
225
-
226
- consoleErrorSpy.mockRestore()
227
- })
228
-
229
- it('should ignore null listeners', () => {
230
- // Should not throw
231
- target.addEventListener('test', null)
232
- target.removeEventListener('test', null)
233
- target.dispatchEvent(new Event('test'))
234
- })
235
-
236
- it('should handle composed path', () => {
237
- let composedPath: readonly EventTarget[] | null = null
238
-
239
- const listener = (event: Event) => {
240
- composedPath = event.composedPath()
241
- }
242
-
243
- target.addEventListener('test', listener)
244
- target.dispatchEvent(new Event('test'))
245
-
246
- expect(composedPath).toEqual([target])
247
- })
248
-
249
- it('should prevent duplicate listeners', () => {
250
- const listener = jest.fn()
251
-
252
- target.addEventListener('test', listener)
253
- target.addEventListener('test', listener) // Same listener
254
-
255
- target.dispatchEvent(new Event('test'))
256
- expect(listener).toHaveBeenCalledTimes(1) // Only called once
257
- })
258
- })
259
-
260
- describe('Event flow integration', () => {
261
- it('should work with CustomEvent dispatch', () => {
262
- const target = new EventTarget()
263
- const listener = jest.fn()
264
- const detail = { message: 'hello' }
265
-
266
- target.addEventListener('custom', listener)
267
-
268
- const event = new CustomEvent('custom', {
269
- detail,
270
- bubbles: true,
271
- cancelable: true,
272
- })
273
-
274
- const result = target.dispatchEvent(event)
275
-
276
- expect(listener).toHaveBeenCalledWith(event)
277
- expect(listener.mock.calls[0][0].detail).toEqual(detail)
278
- expect(result).toBe(true)
279
- })
280
-
281
- it('should handle stopImmediatePropagation', () => {
282
- const target = new EventTarget()
283
- const listener1 = jest.fn((event: Event) => {
284
- event.stopImmediatePropagation()
285
- })
286
- const listener2 = jest.fn()
287
-
288
- target.addEventListener('test', listener1)
289
- target.addEventListener('test', listener2)
290
-
291
- target.dispatchEvent(new Event('test'))
292
-
293
- expect(listener1).toHaveBeenCalledTimes(1)
294
- expect(listener2).toHaveBeenCalledTimes(0) // Stopped
295
- })
296
- })
297
-
298
- describe('Global polyfill installation', () => {
299
- it('should make Event available globally', () => {
300
- // This tests that our polyfill setup works
301
- expect(typeof (global as any).Event).toBe('function')
302
- expect(typeof (global as any).CustomEvent).toBe('function')
303
-
304
- const globalEvent = new (global as any).Event('test')
305
- expect(globalEvent.type).toBe('test')
306
-
307
- const globalCustomEvent = new (global as any).CustomEvent('custom', {
308
- detail: 'test',
309
- })
310
- expect(globalCustomEvent.detail).toBe('test')
311
- })
312
- })
313
- })
@@ -1,5 +0,0 @@
1
- describe('Chat', () => {
2
- it('should do maths', () => {
3
- expect(1 + 1).toBe(2)
4
- })
5
- })
@@ -1,11 +0,0 @@
1
- import { jestTransformPackages } from '../jest'
2
-
3
- describe('jestTransformPackages', () => {
4
- it('exports an array of package patterns', () => {
5
- expect(jestTransformPackages).toEqual([
6
- '@planningcenter/chat-react-native',
7
- '@planningcenter/emoji-keyboard',
8
- '@fortawesome',
9
- ])
10
- })
11
- })
@@ -1,65 +0,0 @@
1
- import { Session, Uri } from '../../utils'
2
-
3
- describe('URI', () => {
4
- it('should be defined', () => {
5
- expect(Uri).toBeDefined()
6
- })
7
-
8
- it('should create a new instance', () => {
9
- const uri = new Uri({
10
- session: new Session({ env: 'production', type: 'OAuth' }),
11
- })
12
- expect(uri).toBeDefined()
13
- })
14
-
15
- describe('baseUrl', () => {
16
- describe('planning center', () => {
17
- it('should return the correct base URL for production', () => {
18
- const uri = new Uri({
19
- session: new Session({ env: 'production', type: 'OAuth' }),
20
- })
21
- expect(uri.baseUrl).toBe('https://api.planningcenteronline.com')
22
- })
23
-
24
- it('should return the correct base URL for staging', () => {
25
- const uri = new Uri({
26
- session: new Session({ env: 'staging', type: 'OAuth' }),
27
- })
28
- expect(uri.baseUrl).toBe('https://api-staging.planningcenteronline.com')
29
- })
30
-
31
- it('should return the correct base URL for development', () => {
32
- const uri = new Uri({
33
- session: new Session({ env: 'development', type: 'OAuth' }),
34
- })
35
- expect(uri.baseUrl).toBe('https://api.pco.test')
36
- })
37
- })
38
-
39
- describe('church center', () => {
40
- it('should return the correct base URL for production', () => {
41
- const uri = new Uri({
42
- session: new Session({ env: 'production', type: 'ChurchCenterOauth' }),
43
- graph: 'churchcenter',
44
- })
45
- expect(uri.baseUrl).toBe('https://api.churchcenter.com')
46
- })
47
-
48
- it('should return the correct base URL for staging', () => {
49
- const uri = new Uri({
50
- session: new Session({ env: 'staging', type: 'ChurchCenterOauth' }),
51
- graph: 'churchcenter',
52
- })
53
- expect(uri.baseUrl).toBe('https://api.staging.churchcenter.com')
54
- })
55
-
56
- it('should return the correct base URL for development', () => {
57
- const uri = new Uri({
58
- session: new Session({ env: 'development', type: 'ChurchCenterOauth' }),
59
- graph: 'churchcenter',
60
- })
61
- expect(uri.baseUrl).toBe('https://api.churchcenter.test')
62
- })
63
- })
64
- })
65
- })