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

ALCS-2345 Added unit tests #1948

Merged
merged 2 commits into from
Oct 31, 2024
Merged

ALCS-2345 Added unit tests #1948

merged 2 commits into from
Oct 31, 2024

Conversation

fbarreta
Copy link
Collaborator

Unit tests added

@fbarreta fbarreta self-assigned this Oct 31, 2024
@@ -33,4 +51,75 @@ describe('NoticeOfIntentTagService', () => {
it('should be defined', () => {
expect(service).toBeDefined();
});

it('should add tag to the application if not existing', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

change application to noi

expect(noiRepositoryMock.save).toHaveBeenCalledTimes(1);
});

it('should raise an error if application is not found', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

await expect(service.addTagToNoticeOfIntent('noi-1', 'tag-name')).rejects.toThrow(ServiceNotFoundException);
});

it('should raise an error if the application already has the tag', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

await expect(service.addTagToNoticeOfIntent('noi-1', 'tag-name')).rejects.toThrow(ServiceValidationException);
});

it('should throw an error if the application does not have any tags when deleting', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

await expect(service.removeTagFromNoticeOfIntent('noi-1', 'tag-name')).rejects.toThrow(ServiceValidationException);
});

it('should throw an error if the application does not have the tag requested when deleting', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

await expect(service.removeTagFromNoticeOfIntent('noi-1', 'tag-name')).rejects.toThrow(ServiceValidationException);
});

it('should delete the tag from application if exists', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

expect(noiRepositoryMock.save).toHaveBeenCalledTimes(1);
});

it('should return application tags', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

expect(result.length).toEqual(1);
});

it('should return empty array if application does not have tags', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@fbarreta fbarreta requested a review from Abradat October 31, 2024 18:11
Copy link
Collaborator

@Abradat Abradat left a comment

Choose a reason for hiding this comment

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

LGTM!

@fbarreta fbarreta merged commit 19427e0 into develop Oct 31, 2024
5 checks passed
@fbarreta fbarreta deleted the feature/2345-add-unit-tests branch October 31, 2024 18:21
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.

2 participants