Skip to content

Commit e2c6f88

Browse files
amritbejAmrit
andauthored
test(shared): add unit tests for getProfileUrl, getWebViewUrl, getDeepLinkUrl (#296)
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 Co-authored-by: Amrit <amrit@example.com>
1 parent b520391 commit e2c6f88

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { getProfileUrl, getWebViewUrl, getDeepLinkUrl } from '../platforms';
3+
4+
// ─── getProfileUrl Tests ───
5+
6+
describe('getProfileUrl', () => {
7+
it('should return the correct GitHub profile URL', () => {
8+
expect(getProfileUrl('github', 'octocat')).toBe('https://github.com/octocat');
9+
});
10+
11+
it('should return the correct LinkedIn profile URL', () => {
12+
expect(getProfileUrl('linkedin', 'john')).toBe('https://www.linkedin.com/in/john');
13+
});
14+
15+
it('should return the correct Twitter profile URL', () => {
16+
expect(getProfileUrl('twitter', 'john')).toBe('https://x.com/john');
17+
});
18+
19+
it('should return empty string for an unknown platform', () => {
20+
expect(getProfileUrl('nonexistent', 'user')).toBe('');
21+
});
22+
});
23+
24+
// ─── getWebViewUrl Tests ───
25+
26+
describe('getWebViewUrl', () => {
27+
it('should return the correct LinkedIn webview URL', () => {
28+
expect(getWebViewUrl('linkedin', 'john')).toBe('https://www.linkedin.com/in/john');
29+
});
30+
31+
it('should return the correct Twitter webview URL', () => {
32+
expect(getWebViewUrl('twitter', 'john')).toBe('https://x.com/john');
33+
});
34+
35+
it('should return null for platforms without a webview URL (github)', () => {
36+
expect(getWebViewUrl('github', 'octocat')).toBeNull();
37+
});
38+
39+
it('should return null for an unknown platform', () => {
40+
expect(getWebViewUrl('nonexistent', 'user')).toBeNull();
41+
});
42+
});
43+
44+
// ─── getDeepLinkUrl Tests ───
45+
46+
describe('getDeepLinkUrl', () => {
47+
it('should return the correct Twitter deep link URL', () => {
48+
expect(getDeepLinkUrl('twitter', 'john')).toBe('twitter://user?screen_name=john');
49+
});
50+
51+
it('should return the correct LinkedIn deep link URL', () => {
52+
expect(getDeepLinkUrl('linkedin', 'john')).toBe('linkedin://profile?id=john');
53+
});
54+
55+
it('should return null for platforms without a deep link (github)', () => {
56+
expect(getDeepLinkUrl('github', 'octocat')).toBeNull();
57+
});
58+
59+
it('should return null for an unknown platform', () => {
60+
expect(getDeepLinkUrl('nonexistent', 'user')).toBeNull();
61+
});
62+
});

0 commit comments

Comments
 (0)