|
| 1 | +import { describe, it, expect } from 'vitest'; |
| 2 | +import { |
| 3 | + PLATFORMS, |
| 4 | + getAllPlatforms, |
| 5 | + getPlatform, |
| 6 | + getProfileUrl, |
| 7 | + getWebViewUrl, |
| 8 | + getDeepLinkUrl, |
| 9 | +} from './platforms'; |
| 10 | + |
| 11 | +// ─── StackOverflow Platform Tests ─── |
| 12 | + |
| 13 | +describe('stackoverflow platform', () => { |
| 14 | + it('should exist in PLATFORMS registry', () => { |
| 15 | + expect(PLATFORMS.stackoverflow).toBeDefined(); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should have correct platform definition', () => { |
| 19 | + const so = PLATFORMS.stackoverflow; |
| 20 | + expect(so.id).toBe('stackoverflow'); |
| 21 | + expect(so.name).toBe('Stack Overflow'); |
| 22 | + expect(so.icon).toBe('stackoverflow'); |
| 23 | + expect(so.color).toBe('#F58025'); |
| 24 | + expect(so.urlPattern).toBe('https://stackoverflow.com/users/{username}'); |
| 25 | + expect(so.followStrategy).toBe('link'); |
| 26 | + expect(so.deepLinkPattern).toBeNull(); |
| 27 | + expect(so.webViewUrlPattern).toBeNull(); |
| 28 | + expect(so.oauthScopes).toEqual([]); |
| 29 | + expect(so.usesFullUrl).toBe(false); |
| 30 | + expect(so.usernamePlaceholder).toBeTruthy(); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should be included in getAllPlatforms()', () => { |
| 34 | + const all = getAllPlatforms(); |
| 35 | + const so = all.find((p) => p.id === 'stackoverflow'); |
| 36 | + expect(so).toBeDefined(); |
| 37 | + expect(so!.name).toBe('Stack Overflow'); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should be retrievable via getPlatform()', () => { |
| 41 | + const so = getPlatform('stackoverflow'); |
| 42 | + expect(so).toBeDefined(); |
| 43 | + expect(so!.id).toBe('stackoverflow'); |
| 44 | + }); |
| 45 | +}); |
| 46 | + |
| 47 | +// ─── getProfileUrl Tests for StackOverflow ─── |
| 48 | + |
| 49 | +describe('getProfileUrl – stackoverflow', () => { |
| 50 | + it('should generate correct URL with user ID and display name', () => { |
| 51 | + const url = getProfileUrl('stackoverflow', '1234/user'); |
| 52 | + expect(url).toBe('https://stackoverflow.com/users/1234/user'); |
| 53 | + }); |
| 54 | + |
| 55 | + it('should generate correct URL with numeric ID only', () => { |
| 56 | + const url = getProfileUrl('stackoverflow', '56789'); |
| 57 | + expect(url).toBe('https://stackoverflow.com/users/56789'); |
| 58 | + }); |
| 59 | + |
| 60 | + it('should return empty string for unknown platform', () => { |
| 61 | + const url = getProfileUrl('nonexistent', '1234'); |
| 62 | + expect(url).toBe(''); |
| 63 | + }); |
| 64 | +}); |
| 65 | + |
| 66 | +// ─── getWebViewUrl / getDeepLinkUrl for StackOverflow ─── |
| 67 | + |
| 68 | +describe('getWebViewUrl / getDeepLinkUrl – stackoverflow', () => { |
| 69 | + it('should return null for webViewUrl (not supported)', () => { |
| 70 | + expect(getWebViewUrl('stackoverflow', '1234/user')).toBeNull(); |
| 71 | + }); |
| 72 | + |
| 73 | + it('should return null for deepLinkUrl (not supported)', () => { |
| 74 | + expect(getDeepLinkUrl('stackoverflow', '1234/user')).toBeNull(); |
| 75 | + }); |
| 76 | +}); |
0 commit comments