Refactor (packages/web/src/components/Share.tsx): Function with many returns - #47
Open
lynseyyyyy wants to merge 2 commits into
Open
Refactor (packages/web/src/components/Share.tsx): Function with many returns#47lynseyyyyy wants to merge 2 commits into
lynseyyyyy wants to merge 2 commits into
Conversation
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.
Issue for this PR
Closes #46
Type of change
What does this PR do?
This PR refactors
getStatusTextinpackages/web/src/components/Share.tsxto replace the switch statement with a status-to-message lookup. The change removes the Qlty "Function with many returns" warning forgetStatusTextwhile keeping the existing status messages, error messages, and the fallback behaviour for unknown status.I also added a separate testing file for unit tests for each status case and configured the web package tests to run through Turbo in CI.
How did you verify your code works?
Share.test.ts, which covers all status values, error messages, and the fallback behaviour for unknown status.getStatusTextanymore.Screenshots / recordings
Qlty before:

Qlty after:

Tests:

Coverage:

Checklist
If you do not follow this template your PR will be automatically rejected.