import { describe, expect, it, vi } from 'vitest' import { handleDeepLink, makeDeepLinks } from '../src/lib/deeplinks' describe('deep links', () => { it('routes an order URL to the order screen with the captured id', () => { const navigate = vi.fn() const links = makeDeepLinks(navigate) expect(handleDeepLink(links, '/orders/42')).toBe(true) expect(navigate).toHaveBeenCalledWith('/orders/42') }) it('matches a full custom-scheme URL (scheme + host stripped) and a universal link', () => { const navigate = vi.fn() const links = makeDeepLinks(navigate) expect(handleDeepLink(links, '{{appName}}://orders/7?ref=push')).toBe(true) expect(handleDeepLink(links, 'https://example.com/orders/7')).toBe(true) expect(navigate).toHaveBeenNthCalledWith(1, '/orders/7') expect(navigate).toHaveBeenNthCalledWith(2, '/orders/7') }) it('routes the settings link', () => { const navigate = vi.fn() expect(handleDeepLink(makeDeepLinks(navigate), '/settings')).toBe(true) expect(navigate).toHaveBeenCalledWith('/settings') }) it('returns false and navigates nowhere for an unknown URL', () => { const navigate = vi.fn() expect(handleDeepLink(makeDeepLinks(navigate), '/nope/nowhere')).toBe(false) expect(navigate).not.toHaveBeenCalled() }) })