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

Added FileAttachmentButton test #271

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

cleobnvntra
Copy link
Contributor

Description

Added unit test for FileAttachmentButton component

Closes #141

What change does this PR introduce?

Please select the relevant option(s).

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to docs/code comments)

What is the proposed approach?

The proposed approach focuses on validating the behavior and rendering of the FileAttachmentButton component, ensuring that it works as expected based on its context and props. This includes:

  1. Rendering Verification:
  • Confirming that the button and input elements are correctly rendered with the expected attributes, such as aria-label, type, accept, and multiple.
  1. State-Dependent Icon Rendering:
  • Testing that the button’s enabled and disabled states render the correct classes and icons based on the blockAllowsAttachment context value.
  1. Preventing Invalid Actions:
  • Verifying that the handleUpload function does not proceed when certain conditions are unmet, such as when getCurrPath returns null.
  1. File Upload Handling:
  • Ensuring that the handleUpload function triggers the correct callbacks and processes file uploads as expected, including calling a mocked file handler with the appropriate arguments.

Checklist:

  • The commit message follows our adopted guidelines
  • Testing has been done for the change(s) added (for bug fixes/features)
  • Relevant comments/docs have been added/updated (for bug fixes/features)

Copy link
Owner

@tjtanjin tjtanjin left a comment

Choose a reason for hiding this comment

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

LGTM!

@tjtanjin tjtanjin merged commit 5f61f8a into tjtanjin:main Nov 21, 2024
11 checks passed
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.

[Task] Add unit test cases for FileAttachmentButton component
2 participants