Skip to content

test: refactor tests for Tag component#328

Merged
adaex merged 4 commits into
mainfrom
feat-tag-test
Jun 10, 2025
Merged

test: refactor tests for Tag component#328
adaex merged 4 commits into
mainfrom
feat-tag-test

Conversation

@adaex

@adaex adaex commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

This pull request enhances the test coverage for the Tag and Tag.List components in packages/arcodesign/components/tag/__test__/index.spec.js. It introduces new test cases to verify component behavior under various scenarios, including mounting/unmounting, event handling, style rendering, and edge cases. Additionally, it improves the organization and clarity of the test descriptions by adding comments in both English and Chinese.

Enhancements to Tag component tests:

  • Replaced individual mount tests with a consolidated test to verify mounting and unmounting behavior across different props.
  • Added tests for click event handling, including tag click and close button click, with mock functions to validate callbacks.
  • Expanded style rendering tests to include various combinations of props like type, size, filleted, halfBorder, and custom colors.
  • Introduced tests for rendering icons and handling the closeable property, ensuring proper display and behavior.

Addition of Tag.List component tests:

  • Added tests for padding configuration, verifying both string and numeric values for vertical and horizontal padding.
  • Implemented tests for the add button functionality, including default, custom, and hidden add button scenarios.
  • Verified tag interactions, styling inheritance, and custom styles, including handling of closeable tags and edge cases like empty lists.

@adaex adaex requested a review from Copilot June 5, 2025 10:43

This comment was marked as outdated.

@codecov

codecov Bot commented Jun 5, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.82%. Comparing base (e04f22e) to head (73cb9e3).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #328      +/-   ##
==========================================
+ Coverage   89.71%   89.82%   +0.10%     
==========================================
  Files         141      141              
  Lines        8393     8393              
  Branches     3447     3447              
==========================================
+ Hits         7530     7539       +9     
+ Misses        835      828       -7     
+ Partials       28       26       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 5, 2025

Copy link
Copy Markdown

PR Preview Link: https://preview-328-arco-design-mobile.surge.sh

@adaex adaex requested a review from Copilot June 5, 2025 10:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a comprehensive set of tests for the Tag component and its List variant to ensure they render correctly with variations in type, size, style, and behavior.

  • New tests for different tag types, sizes, colors, and icons.
  • Additional tests for Tag.List including padding configurations, add area customization, and callback functions for close and add actions.
Comments suppressed due to low confidence (2)

packages/arcodesign/components/tag/test/index.spec.js:66

  • Ensure that 'prefix' is defined or imported in this test file to make the test self-contained.
expect(container1.querySelector(`.${prefix}-primary`)).toBeInTheDocument();

packages/arcodesign/components/tag/test/index.spec.js:150

  • Confirm that 'defaultContext' is available in the test scope or imported correctly to prevent reference errors.
const listElement1 = container1.querySelector(`.${defaultContext.prefixCls}-tag-list`);

@adaex adaex added the unit test label Jun 5, 2025
@adaex adaex changed the title test: add tests for different types, sizes, and styles of the Tag component test: refactor tests for Tag component Jun 10, 2025
@adaex adaex requested review from tangshumin666 and ziqisia June 10, 2025 11:38
@adaex adaex merged commit 409c0b0 into main Jun 10, 2025
7 of 9 checks passed
@adaex adaex deleted the feat-tag-test branch June 10, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants