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 unit tests #2

Merged
merged 5 commits into from
Oct 2, 2024
Merged

added unit tests #2

merged 5 commits into from
Oct 2, 2024

Conversation

bogdan-rosianu
Copy link
Collaborator

No description provided.

expect(receivedEvents[0].timestamp).toEqual(123);
expect(axios.post).toHaveBeenCalledTimes(2);
});

Copy link

Choose a reason for hiding this comment

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

It would be useful to add a test that checks the behavior of the class when the call to Elasticsearch fails (eg using jest.MockRejectedValue to simulate a network error). This would cover cases of failure handling.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Excelent! code coverage went to 98% :D

onEventsReceived: async (highestTimestamp, events) => {receivedEvents = events;},
setLastProcessedTimestamp: async (timestamp: number) => {},
});

Copy link

Choose a reason for hiding this comment

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

add expect for mockResponse just to check that the response from ElasticSearch is []

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, since I won't receive anything because the es response doesn't contain any hit

@bogdan-rosianu bogdan-rosianu changed the base branch from SERVICES-2607-event-processor to main October 2, 2024 13:33
@bogdan-rosianu bogdan-rosianu merged commit ce49d78 into main Oct 2, 2024
1 check passed
@tanghel tanghel deleted the SERVICES-2607-unit-tests branch October 2, 2024 13:35
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.

3 participants