Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add unit test for src/SearchResultCard/index.tsx #306

Closed

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Mar 26, 2025

Trigger Info

Trigger Type Triggered By Source File Assignment
Push canisminor1990 src/SearchResultCard/index.tsx Detail

Summary

This PR introduces unit tests for the SearchResultCard component to ensure its functionality and behavior under various scenarios. Key changes include:

  • Export Adjustments: Updated SearchResultCard to export both the component and useStyles for potential reuse.

  • Unit Tests: Added comprehensive test cases in tests/index.test.ts to validate:

    • Rendering with valid URLs and titles.

    • Handling of invalid URLs.

    • Behavior when minimal props are provided.

    • Fallbacks for alt text when title or alt are missing.

    • Proper display of URL-derived titles.

These tests enhance the reliability of the SearchResultCard component and ensure consistent behavior across edge cases.

Coverage

The change in coverage value, such as: 0% -> 50%, indicates that the coverage was 0% before writing the tests and 50% after writing them.

https://web.dev/articles/ta-code-coverage

Type Change
lines 0% -> 100% 🔺
functions 100% -> 100%
statements 0% -> 100% 🔺
branches 100% -> 100%
source program

Test Statuses

Status Change
passed 0 -> 6 🔺
failed 0 -> 0
skipped 0 -> 0
source program

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Tip

You can @gru-agent rebase to rebase the PR.

Tip

You can @gru-agent redo to reset or rebase before redoing the PR.

Tip

To modify the test code yourself, click here Edit Test Code

Copy link

vercel bot commented Mar 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
lobe-ui ✅ Ready (Inspect) Visit Preview Mar 26, 2025 8:22am

@lobehubbot
Copy link
Member

👍 @gru-agent[bot]


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

pkg-pr-new bot commented Mar 26, 2025

Open in Stackblitz

npm i https://pkg.pr.new/lobehub/lobe-ui/@lobehub/ui@306

commit: 9d4b5bb

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.

2 participants