Skip to content

feat(shared): add isSupportedPlatform helper and unit tests - #555

Merged
ShantKhatri merged 3 commits into
Dev-Card:mainfrom
Satvik-art-creator:feat/add-isSupportedPlatform-helper
Jun 13, 2026
Merged

feat(shared): add isSupportedPlatform helper and unit tests#555
ShantKhatri merged 3 commits into
Dev-Card:mainfrom
Satvik-art-creator:feat/add-isSupportedPlatform-helper

Conversation

@Satvik-art-creator

Copy link
Copy Markdown
Contributor
  • Add exported isSupportedPlatform helper to platforms.ts

  • Add tests in tests/platforms.test.ts for existing and unknown platform IDs

Closes #9

Summary

Adds a new isSupportedPlatform(id: string): boolean helper function to packages/shared/src/platforms.ts that safely checks whether a given platform ID exists in the PLATFORMS registry. This improves API discoverability and provides a clean, type-safe way to validate platform IDs without directly accessing the registry object. Corresponding unit tests are added covering all registered platforms, specific known IDs, and edge cases (unknown IDs, empty strings, case sensitivity).

Closes #9

This PR is submitted as part of GSSoC '26 (GirlScript Summer of Code 2026).


Type of Change

  • Bug fix
  • New feature
  • Refactor (no functional change)
  • UI / Design change
  • Tests only
  • Documentation
  • Infrastructure / DevOps
  • Security

What Changed

  • packages/shared/src/platforms.ts — Added isSupportedPlatform(id: string): boolean helper using PLATFORMS[id] !== undefined, placed alongside existing helpers (getPlatform, getAllPlatforms).
  • packages/shared/src/__tests__/platforms.test.ts — New test file with 8 test cases covering: all registered platform IDs return true, specific platforms (github, linkedin, twitter, stackoverflow), and edge cases where unknown/empty/misspelled IDs return false.

How to Test

  1. Navigate to the project root.
  2. Install shared package dependencies: npm --prefix packages/shared install
  3. Run the shared package tests: npx --prefix packages/shared vitest run
  4. Verify all 42 tests pass (including 8 new tests in __tests__/platforms.test.ts).

Checklist

  • My code follows the project's coding style (pnpm -r run lint passes).
  • TypeScript compiles without errors (pnpm -r run typecheck).
  • I have added or updated tests for the changes I made.
  • All tests pass locally (pnpm -r run test).
  • I have updated documentation where necessary.
  • No new console.log or debug statements left in the code.
  • Breaking changes are documented in this PR description.

Screenshots / Recordings

N/A — No UI changes.


Additional Context

  • This is a low-risk, additive change with no breaking impact on existing code.
  • The helper is automatically exported via packages/shared/src/index.ts (which re-exports * from './platforms'), making it immediately available to all consumers of @devcard/shared.
  • Contribution made under GSSoC '26.

- Add exported isSupportedPlatform helper to platforms.ts

- Add tests in __tests__/platforms.test.ts for existing and unknown platform IDs

Closes Dev-Card#9
Copilot AI review requested due to automatic review settings June 12, 2026 07:57
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

@Satvik-art-creator is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

CI — All Checks Passed

Backend — SKIP

Check Result
Lint -
Test -
Typecheck -

Mobile — SKIP

Check Result
Lint -
Test -

Web — SKIP

Check Result
Check -
Build -

Last updated: Fri, 12 Jun 2026 08:05:41 GMT

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a small utility to check whether a platform ID is registered, along with Vitest coverage for expected true/false cases.

Changes:

  • Added isSupportedPlatform(id) helper to the shared platforms registry module
  • Added Vitest tests covering known/unknown platform IDs and casing behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/shared/src/platforms.ts Adds isSupportedPlatform to check existence of a platform ID in PLATFORMS.
packages/shared/src/tests/platforms.test.ts Introduces unit tests for isSupportedPlatform across valid/invalid inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/shared/src/platforms.ts
Comment thread packages/shared/src/__tests__/platforms.test.ts Outdated
Comment thread packages/shared/src/__tests__/platforms.test.ts Outdated
- Use Object.prototype.hasOwnProperty.call for safer own-property check

- Remove redundant per-platform assertions covered by the loop test

- Rename misleading test description to reflect casing check intent
@Satvik-art-creator

Copy link
Copy Markdown
Contributor Author

@ShantKhatri Kindly review my pr and merge it under the GSSOC 26 program

@ShantKhatri
ShantKhatri merged commit 11b1a8d into Dev-Card:main Jun 13, 2026
5 of 6 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Congratulations @Satvik-art-creator on getting PR #555 merged!

Thank you for your contribution to the project.

To receive the appropriate GSSoC labels and recognition, please mention @Harxhit in the #get-labels channel on our Discord server and share your merged PR link.

@Harxhit Harxhit added gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. level:intermediate Moderate difficulty contribution requiring some project understanding. (+35 pts) quality:clean PR is well-structured, readable, and follows good practices. (×1.2 multiplier) type:testing Adds/improves tests (+10 pts) type:performance Performance optimization (+15 pts) type:refactor Code refactoring/cleanup (+10 pts) labels Jun 13, 2026
Harxhit pushed a commit to Harxhit/DevCard that referenced this pull request Jun 21, 2026
…#555)

* feat(shared): add isSupportedPlatform helper and unit tests

- Add exported isSupportedPlatform helper to platforms.ts

- Add tests in __tests__/platforms.test.ts for existing and unknown platform IDs

Closes Dev-Card#9

* fix(shared): address Copilot review feedback on isSupportedPlatform

- Use Object.prototype.hasOwnProperty.call for safer own-property check

- Remove redundant per-platform assertions covered by the loop test

- Rename misleading test description to reflect casing check intent

* fix(shared): add vitest types to tsconfig for IDE type resolution
ShantKhatri pushed a commit to ShantKhatri/DevCard that referenced this pull request Jun 23, 2026
…#555)

* feat(shared): add isSupportedPlatform helper and unit tests

- Add exported isSupportedPlatform helper to platforms.ts

- Add tests in __tests__/platforms.test.ts for existing and unknown platform IDs

Closes Dev-Card#9

* fix(shared): address Copilot review feedback on isSupportedPlatform

- Use Object.prototype.hasOwnProperty.call for safer own-property check

- Remove redundant per-platform assertions covered by the loop test

- Rename misleading test description to reflect casing check intent

* fix(shared): add vitest types to tsconfig for IDE type resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. level:intermediate Moderate difficulty contribution requiring some project understanding. (+35 pts) quality:clean PR is well-structured, readable, and follows good practices. (×1.2 multiplier) type:performance Performance optimization (+15 pts) type:refactor Code refactoring/cleanup (+10 pts) type:testing Adds/improves tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shared: add missing getPlatform() type-check helper and unit tests

4 participants