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 entry controller tests #212

Merged
merged 10 commits into from
Jan 10, 2025
Merged

Conversation

hiyaryan
Copy link
Member

This PR tests the entry controller with unit tests. The initial commit sets up the test suite and adds unit tests for getAllEntries.

- Set up test suite.
  - Mock `EntryServices`, `Request`, `Response`, and `NextFunction`.

- Create test suite for `EntryController`.
  - Add tests for `getAllEntries`.
@hiyaryan hiyaryan added test Add or improve testing api Improvements to the API labels Dec 30, 2024
@hiyaryan hiyaryan self-assigned this Dec 30, 2024
@hiyaryan hiyaryan marked this pull request as draft December 30, 2024 23:36
- Add `createEntry` tests.
- Update mocks.
  - Simplify `mockReq`.
  - Make `mockNext` a `jest.Mock`.
- Remove mocked services that there are no tests for.
- Update `getEntry` wrt the updated `mockReq`.
- Add unit tests for updateEntry.
- Add unit tests for deleteEntry.
- Add unit tests for getEntryAnalysis.
  - Resolve error: `entryAnalysis.toObject` is not a function.
    - Remove unnecessary toObject cast.
- Add updateEntryAnalysis tests.
- Remove unnecessary toObject cast on entryAnalysis returned from updateEntryAnalysis service.
…tryConversation tests

- Add `getEntryConversation` tests.
  - Remove unnecessary `toObject` cast.
- Add `createEntryConversation` tests.
  - Remove unused logic to check for empty response.
    - An error will be thrown by `getAnalysisCompletion` in entryConversation.ts before this logic is reached.
- Add `updateEntryConversation` tests.
  - Remove unnecessary `toObject` cast.
  - Note that flash messages are not sent on successful update (see FIXME).
- Add test to `createEntry` test sub-suite.
@hiyaryan hiyaryan requested a review from ishaan000 January 9, 2025 23:20
@hiyaryan hiyaryan marked this pull request as ready for review January 10, 2025 00:44
@hiyaryan hiyaryan changed the title test: test entry controllers test: add entry controller tests Jan 10, 2025
Copy link
Collaborator

@ishaan000 ishaan000 left a comment

Choose a reason for hiding this comment

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

Looks good. Nice work! 😁

@hiyaryan hiyaryan merged commit ecbf047 into 139-ts-migration Jan 10, 2025
@hiyaryan hiyaryan deleted the 139-controller-tests branch January 10, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Improvements to the API test Add or improve testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants