From 1177a0ec04a9c1241687aca624dd463062096b40 Mon Sep 17 00:00:00 2001 From: Amrit Date: Sun, 24 May 2026 00:48:42 +0530 Subject: [PATCH] test(shared): add unit tests for getProfileUrl, getWebViewUrl, getDeepLinkUrl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #10 - tests getProfileUrl('github', 'octocat') → https://github.com/octocat - tests getWebViewUrl('linkedin', 'john') → correct LinkedIn webview URL - tests getDeepLinkUrl('twitter', 'john') → correct Twitter deep link URL - covers null returns for unsupported and unknown platforms - follows existing Vitest describe/it/expect style --- .../src/__tests__/platforms-url.test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 packages/shared/src/__tests__/platforms-url.test.ts diff --git a/packages/shared/src/__tests__/platforms-url.test.ts b/packages/shared/src/__tests__/platforms-url.test.ts new file mode 100644 index 0000000..cbfac37 --- /dev/null +++ b/packages/shared/src/__tests__/platforms-url.test.ts @@ -0,0 +1,62 @@ +import { describe, it, expect } from 'vitest'; +import { getProfileUrl, getWebViewUrl, getDeepLinkUrl } from '../platforms'; + +// ─── getProfileUrl Tests ─── + +describe('getProfileUrl', () => { + it('should return the correct GitHub profile URL', () => { + expect(getProfileUrl('github', 'octocat')).toBe('https://github.com/octocat'); + }); + + it('should return the correct LinkedIn profile URL', () => { + expect(getProfileUrl('linkedin', 'john')).toBe('https://www.linkedin.com/in/john'); + }); + + it('should return the correct Twitter profile URL', () => { + expect(getProfileUrl('twitter', 'john')).toBe('https://x.com/john'); + }); + + it('should return empty string for an unknown platform', () => { + expect(getProfileUrl('nonexistent', 'user')).toBe(''); + }); +}); + +// ─── getWebViewUrl Tests ─── + +describe('getWebViewUrl', () => { + it('should return the correct LinkedIn webview URL', () => { + expect(getWebViewUrl('linkedin', 'john')).toBe('https://www.linkedin.com/in/john'); + }); + + it('should return the correct Twitter webview URL', () => { + expect(getWebViewUrl('twitter', 'john')).toBe('https://x.com/john'); + }); + + it('should return null for platforms without a webview URL (github)', () => { + expect(getWebViewUrl('github', 'octocat')).toBeNull(); + }); + + it('should return null for an unknown platform', () => { + expect(getWebViewUrl('nonexistent', 'user')).toBeNull(); + }); +}); + +// ─── getDeepLinkUrl Tests ─── + +describe('getDeepLinkUrl', () => { + it('should return the correct Twitter deep link URL', () => { + expect(getDeepLinkUrl('twitter', 'john')).toBe('twitter://user?screen_name=john'); + }); + + it('should return the correct LinkedIn deep link URL', () => { + expect(getDeepLinkUrl('linkedin', 'john')).toBe('linkedin://profile?id=john'); + }); + + it('should return null for platforms without a deep link (github)', () => { + expect(getDeepLinkUrl('github', 'octocat')).toBeNull(); + }); + + it('should return null for an unknown platform', () => { + expect(getDeepLinkUrl('nonexistent', 'user')).toBeNull(); + }); +});