feat: add isSupportedPlatform helper and URL function unit tests#65
Open
SdSarthak wants to merge 2 commits into
Open
feat: add isSupportedPlatform helper and URL function unit tests#65SdSarthak wants to merge 2 commits into
SdSarthak wants to merge 2 commits into
Conversation
- Add isSupportedPlatform(id) boolean helper to platforms.ts - Write platforms.test.ts covering known/unknown/empty/case-sensitive IDs - Write platforms-url.test.ts covering getProfileUrl, getWebViewUrl, getDeepLinkUrl - Add vitest devDependency and test script to shared package.json Closes Dev-Card#9 Closes Dev-Card#10
There was a problem hiding this comment.
Pull request overview
Adds a small shared-platform API helper plus initial unit test coverage for platform URL helpers within @devcard/shared, and wires up Vitest to run the new tests in this package.
Changes:
- Add
isSupportedPlatform(id: string): booleanto check whether a platform ID exists in the registry. - Add Vitest unit tests for
isSupportedPlatform,getProfileUrl,getWebViewUrl, andgetDeepLinkUrl. - Add
vitestand atestscript topackages/shared/package.json.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/shared/src/platforms.ts | Adds isSupportedPlatform helper alongside existing platform registry + URL helpers. |
| packages/shared/src/tests/platforms.test.ts | Adds unit tests for isSupportedPlatform. |
| packages/shared/src/tests/platforms-url.test.ts | Adds unit tests for profile/webview/deeplink URL helper functions. |
| packages/shared/package.json | Adds vitest devDependency and test script for the shared package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| /** Returns true if the given id corresponds to a registered platform */ | ||
| export function isSupportedPlatform(id: string): boolean { | ||
| return PLATFORMS[id] !== undefined; |
|
|
||
| it('returns false for GITHUB (case-sensitive check)', () => { | ||
| expect(isSupportedPlatform('GITHUB')).toBe(false); | ||
| }); |
| "devDependencies": { | ||
| "typescript": "^5.4.0" | ||
| "typescript": "^5.4.0", | ||
| "vitest": "^1.6.0" |
…0, add prototype key test
Author
|
Fixed in the follow-up commit:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isSupportedPlatform(id: string): booleanhelper topackages/shared/src/platforms.tsthat checks if a given platform ID exists in the registrypackages/shared/src/__tests__/platforms.test.tswith vitest tests covering known IDs (github,linkedin), unknown IDs (myspace), empty string, and case-sensitivitypackages/shared/src/__tests__/platforms-url.test.tswith vitest tests forgetProfileUrl,getWebViewUrl, andgetDeepLinkUrlcovering both valid and invalid/null casesvitestdevDependency and"test": "vitest run"script topackages/shared/package.jsonCloses #9
Closes #10
Test plan
isSupportedPlatform('github')→trueisSupportedPlatform('linkedin')→trueisSupportedPlatform('myspace')→falseisSupportedPlatform('')→falseisSupportedPlatform('GITHUB')→false(case-sensitive)getProfileUrl('github', 'octocat')→'https://github.com/octocat'getProfileUrl('linkedin', 'johndoe')→'https://www.linkedin.com/in/johndoe'getProfileUrl('unknown', 'x')→''getWebViewUrl('linkedin', 'johndoe')→'https://www.linkedin.com/in/johndoe'getWebViewUrl('github', 'octocat')→nullgetDeepLinkUrl('twitter', 'elonmusk')→'twitter://user?screen_name=elonmusk'getDeepLinkUrl('github', 'octocat')→null🤖 Generated with Claude Code