Skip to content

feat: add isSupportedPlatform helper and URL function unit tests#65

Open
SdSarthak wants to merge 2 commits into
Dev-Card:mainfrom
SdSarthak:feat/shared-platform-helpers
Open

feat: add isSupportedPlatform helper and URL function unit tests#65
SdSarthak wants to merge 2 commits into
Dev-Card:mainfrom
SdSarthak:feat/shared-platform-helpers

Conversation

@SdSarthak
Copy link
Copy Markdown

Summary

  • Add isSupportedPlatform(id: string): boolean helper to packages/shared/src/platforms.ts that checks if a given platform ID exists in the registry
  • Add packages/shared/src/__tests__/platforms.test.ts with vitest tests covering known IDs (github, linkedin), unknown IDs (myspace), empty string, and case-sensitivity
  • Add packages/shared/src/__tests__/platforms-url.test.ts with vitest tests for getProfileUrl, getWebViewUrl, and getDeepLinkUrl covering both valid and invalid/null cases
  • Add vitest devDependency and "test": "vitest run" script to packages/shared/package.json

Closes #9
Closes #10

Test plan

  • isSupportedPlatform('github')true
  • isSupportedPlatform('linkedin')true
  • isSupportedPlatform('myspace')false
  • isSupportedPlatform('')false
  • isSupportedPlatform('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')null
  • getDeepLinkUrl('twitter', 'elonmusk')'twitter://user?screen_name=elonmusk'
  • getDeepLinkUrl('github', 'octocat')null

🤖 Generated with Claude Code

- 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
Copilot AI review requested due to automatic review settings May 10, 2026 18:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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): boolean to check whether a platform ID exists in the registry.
  • Add Vitest unit tests for isSupportedPlatform, getProfileUrl, getWebViewUrl, and getDeepLinkUrl.
  • Add vitest and a test script to packages/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.

Comment thread packages/shared/src/platforms.ts Outdated

/** 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);
});
Comment thread packages/shared/package.json Outdated
"devDependencies": {
"typescript": "^5.4.0"
"typescript": "^5.4.0",
"vitest": "^1.6.0"
@SdSarthak
Copy link
Copy Markdown
Author

Fixed in the follow-up commit:

  • isSupportedPlatform now uses Object.prototype.hasOwnProperty.call(PLATFORMS, id) so inherited keys like toString and constructor correctly return false.
  • Added a test case covering toString, constructor, and __proto__ to prevent regressions.
  • Aligned vitest version to ^2.0.0 to match the rest of the workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shared: add test coverage for getProfileUrl, getWebViewUrl, getDeepLinkUrl shared: add missing getPlatform() type-check helper and unit tests

2 participants