@planningcenter/chat-react-native 4.8.0-rc.2 → 4.8.0-rc.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "4.8.0-rc.2",
3
+ "version": "4.8.0-rc.3",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -84,5 +84,5 @@
84
84
  "sf-symbols-typescript": "^2.2.0",
85
85
  "typescript": "~6.0.3"
86
86
  },
87
- "gitHead": "4330cc04c3056e5b57682030b8d0ef7e7926b1de"
87
+ "gitHead": "2356bb549118981f9e59602581f64391620151a0"
88
88
  }
@@ -47,6 +47,16 @@ const wrapper = ({ children }: { children: React.ReactNode }) => (
47
47
  <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
48
48
  )
49
49
 
50
+ // A mutation left pending keeps Jest alive: with no observers, TanStack Query
51
+ // re-arms its gc timer until the mutation settles.
52
+ let settlePatch: (() => void) | undefined
53
+ const mockPendingPatch = () =>
54
+ mockPatch.mockReturnValue(
55
+ new Promise(resolve => {
56
+ settlePatch = () => resolve({ data: {} })
57
+ })
58
+ )
59
+
50
60
  const renderHide = (target: ConversationResource = conversation, hidden?: boolean) =>
51
61
  renderHook(() => useHideConversation({ conversation: target, hidden }), { wrapper })
52
62
 
@@ -63,12 +73,14 @@ describe('useHideConversation', () => {
63
73
  jest.spyOn(Alert, 'alert').mockImplementation(() => {})
64
74
  })
65
75
 
66
- afterEach(() => {
76
+ afterEach(async () => {
77
+ await act(async () => settlePatch?.())
78
+ settlePatch = undefined
67
79
  jest.restoreAllMocks()
68
80
  })
69
81
 
70
82
  it('removes the conversation from every list before the request resolves', async () => {
71
- mockPatch.mockReturnValue(new Promise(() => {}))
83
+ mockPendingPatch()
72
84
  const { result } = renderHide()
73
85
 
74
86
  await act(async () => result.current.setHidden(true))
@@ -152,7 +164,7 @@ describe('useHideConversation', () => {
152
164
  })
153
165
 
154
166
  it('removes the conversation from the hidden list before the request resolves', async () => {
155
- mockPatch.mockReturnValue(new Promise(() => {}))
167
+ mockPendingPatch()
156
168
  const { result } = renderHide(conversation, true)
157
169
 
158
170
  expect(result.current.hidden).toBe(true)