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] [Issue- 221] : Add unit test for ChatBot #291

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

kallel-anobom
Copy link
Contributor

Description

This change includes the setup of mocks for dependencies used in the ChatBot component tests. It mocks the idGenerator, ChatBotContext, ChatBotLoader, and ChatBotContainer to isolate the component being tested and ensure that the tests are not affected by the actual implementations of these dependencies.

Closes #221

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?

Please give a short overview/explanation on the approach taken to resolve the issue(s).

UUID Generation: Mocked idGenerator to return a consistent UUID ("mocked-uuid") using jest.fn().
ChatBot Context: Mocked useChatBotContext hook and ChatBotProvider component to provide controlled context values.
Component Mocks: Mocked ChatBotLoader and ChatBotContainer components to return simple test elements.
Isolation: Ensured ChatBot component tests are isolated from external factors, making tests reliable and focused on the component itself.

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 2747c08 into tjtanjin:main Feb 11, 2025
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 ChatBot component
2 participants