mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
SELF-1768: fix deeplink navigation (#1598)
* fix deeplink navigation * fix tests * fix typing --------- Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>
This commit is contained in:
@@ -36,6 +36,7 @@ jest.mock('@/navigation', () => ({
|
||||
navigate: jest.fn(),
|
||||
isReady: jest.fn(() => true),
|
||||
reset: jest.fn(),
|
||||
getCurrentRoute: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -66,6 +67,10 @@ describe('deeplinks', () => {
|
||||
setDeepLinkUserDetails,
|
||||
});
|
||||
mockPlatform.OS = 'ios';
|
||||
|
||||
// Setup default getCurrentRoute mock to return Splash (cold launch scenario)
|
||||
const { navigationRef } = require('@/navigation');
|
||||
navigationRef.getCurrentRoute.mockReturnValue({ name: 'Splash' });
|
||||
});
|
||||
|
||||
describe('handleUrl', () => {
|
||||
@@ -156,9 +161,10 @@ describe('deeplinks', () => {
|
||||
|
||||
const { navigationRef } = require('@/navigation');
|
||||
// Should navigate to HomeScreen, which will show confirmation modal
|
||||
// During cold launch (Splash screen), reset is called with full navigation state
|
||||
expect(navigationRef.reset).toHaveBeenCalledWith({
|
||||
index: 0,
|
||||
routes: [{ name: 'Home' }],
|
||||
index: 1,
|
||||
routes: [{ name: 'Home' }, { name: 'Home' }],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -598,7 +604,7 @@ describe('deeplinks', () => {
|
||||
mockLinking.getInitialURL.mockResolvedValue(undefined as any);
|
||||
mockLinking.addEventListener.mockReturnValue({ remove });
|
||||
|
||||
const cleanup = setupUniversalLinkListenerInNavigation();
|
||||
const cleanup = setupUniversalLinkListenerInNavigation({} as SelfClient);
|
||||
expect(mockLinking.addEventListener).toHaveBeenCalled();
|
||||
cleanup();
|
||||
expect(remove).toHaveBeenCalled();
|
||||
|
||||
Reference in New Issue
Block a user