Skip to content

Commit 5fd7275

Browse files
committed
test(voip): harden navigateToCallRoom tests for guards and call order
- Assert Navigation.navigate and toggleFocus stay untouched on early exits - Assert toggleFocus and ChatsStackNavigator navigation run before goRoom Made-with: Cursor
1 parent 3bc0654 commit 5fd7275

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/lib/services/voip/navigateToCallRoom.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('navigateToCallRoom', () => {
6666

6767
expect(mockGoRoom).not.toHaveBeenCalled();
6868
expect(toggleFocus).not.toHaveBeenCalled();
69+
expect(mockNavigation.navigate).not.toHaveBeenCalled();
6970
});
7071

7172
it('does not navigate for SIP contact', async () => {
@@ -81,6 +82,8 @@ describe('navigateToCallRoom', () => {
8182
await navigateToCallRoom();
8283

8384
expect(mockGoRoom).not.toHaveBeenCalled();
85+
expect(toggleFocus).not.toHaveBeenCalled();
86+
expect(mockNavigation.navigate).not.toHaveBeenCalled();
8487
});
8588

8689
it('does not navigate when username is missing', async () => {
@@ -96,6 +99,8 @@ describe('navigateToCallRoom', () => {
9699
await navigateToCallRoom();
97100

98101
expect(mockGoRoom).not.toHaveBeenCalled();
102+
expect(toggleFocus).not.toHaveBeenCalled();
103+
expect(mockNavigation.navigate).not.toHaveBeenCalled();
99104
});
100105

101106
it('minimizes first when CallView is focused then navigates', async () => {
@@ -115,6 +120,7 @@ describe('navigateToCallRoom', () => {
115120
item: { rid: 'rid-1', name: 'alice', t: SubscriptionType.DIRECT },
116121
isMasterDetail: true
117122
});
123+
expect(toggleFocus.mock.invocationCallOrder[0]).toBeLessThan(mockGoRoom.mock.invocationCallOrder[0]);
118124
});
119125

120126
it('navigates without toggleFocus when already minimized', async () => {
@@ -154,6 +160,7 @@ describe('navigateToCallRoom', () => {
154160
item: { rid: 'rid-1', name: 'alice', t: SubscriptionType.DIRECT },
155161
isMasterDetail: true
156162
});
163+
expect(mockNavigation.navigate.mock.invocationCallOrder[0]).toBeLessThan(mockGoRoom.mock.invocationCallOrder[0]);
157164
});
158165

159166
it('navigates to ChatsStackNavigator first when on AccessibilityAndAppearanceView', async () => {
@@ -171,6 +178,7 @@ describe('navigateToCallRoom', () => {
171178

172179
expect(mockNavigation.navigate).toHaveBeenCalledWith('ChatsStackNavigator');
173180
expect(mockGoRoom).toHaveBeenCalled();
181+
expect(mockNavigation.navigate.mock.invocationCallOrder[0]).toBeLessThan(mockGoRoom.mock.invocationCallOrder[0]);
174182
});
175183

176184
it('navigates to ChatsStackNavigator first when on SettingsView', async () => {
@@ -188,6 +196,7 @@ describe('navigateToCallRoom', () => {
188196

189197
expect(mockNavigation.navigate).toHaveBeenCalledWith('ChatsStackNavigator');
190198
expect(mockGoRoom).toHaveBeenCalled();
199+
expect(mockNavigation.navigate.mock.invocationCallOrder[0]).toBeLessThan(mockGoRoom.mock.invocationCallOrder[0]);
191200
});
192201

193202
it('does not navigate to ChatsStackNavigator when already on RoomView', async () => {

0 commit comments

Comments
 (0)