Added Test-cases InputValidator Plugin #4
Merged
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.
Description
This pull request introduces comprehensive unit tests and configurations for the
input-validatorproject, improving the test coverage, validating core functionality, and enhancing code quality and reliability.What change does this PR introduce?
Added Unit Tests:
Core Functionality:
validateFile.test.ts: Tests various cases for file validation (valid, invalid, empty, and oversized files).getValidator.test.ts: Ensures thegetValidatorutility retrieves correct validators or returnsundefinedfor invalid cases.getPromptStyles.test.ts: Validates style generation for different prompt types (error,success, etc.).mergePluginConfig.test.ts: Ensures user configurations are merged properly with default plugin configurations.useRcbPlugin.test.ts: Tests plugin behavior including text input, file upload validations, and event handling.Configuration Files:
jest.config.js: Configures Jest for testing.setup.jest.js: Adds polyfills (e.g.,structuredClone) and sets up the environment for consistent test execution.Closes issue #3
What is the proposed approach?
The PR covers:
mergePluginConfig,getValidator,getPromptStyles) behave correctly under various configurations.null/undefinedinputs, event listener behavior, and default configurations.setup.jest.jsto provide consistent polyfills forstructuredCloneand other necessary utilities.Checklist:
validateFile,getValidator,mergePluginConfig,getPromptStyles, anduseRcbPlugin.jest.config.jsfor comprehensive test runs.setup.jest.jsfor environment consistency.Testing Summary:
This PR ensures:
useRcbPluginbehave as expected for text inputs and file uploads.Feel free to review and suggest additional improvements or scenarios for coverage.