Skip to content

Commit

Permalink
ALCS-2353 Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarreta committed Nov 6, 2024
1 parent 9c0038c commit 05bee2d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { initTagCategoryMockEntity } from '../../../../test/mocks/mockEntities';
import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes';
import { TagCategory } from './tag-category.entity';
import { TagCategoryDto } from './tag-category.dto';
import { UpdateResult } from 'typeorm';

describe('TagCategoryController', () => {
let controller: TagCategoryController;
Expand Down Expand Up @@ -62,20 +63,17 @@ describe('TagCategoryController', () => {
name: mockCategoryTag.name,
} as TagCategoryDto;

const result = await controller.update(
mockCategoryTag.uuid,
categoryToUpdate,
);
const result = await controller.update(mockCategoryTag.uuid, categoryToUpdate);

expect(tagCategoryService.update).toHaveBeenCalledTimes(1);
expect(result).toEqual(mockCategoryTag);
});

it('should delete a tag category', async () => {
tagCategoryService.delete.mockResolvedValue(mockCategoryTag);
tagCategoryService.delete.mockResolvedValue({} as UpdateResult);

const result = await controller.delete(mockCategoryTag.uuid);
expect(tagCategoryService.delete).toHaveBeenCalledTimes(1);
expect(result).toEqual(mockCategoryTag);
expect(result).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('TagCategoryService', () => {
}).compile();

service = module.get<TagCategoryService>(TagCategoryService);
tagCategoryRepositoryMock.find.mockResolvedValue([]);
tagCategoryRepositoryMock.findOne.mockResolvedValue(mockTagCategoryEntity);
tagCategoryRepositoryMock.findOneOrFail.mockResolvedValue(mockTagCategoryEntity);
tagCategoryRepositoryMock.save.mockResolvedValue(mockTagCategoryEntity);
Expand Down
1 change: 1 addition & 0 deletions services/apps/alcs/src/alcs/tag/tag.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('TagController', () => {

it('should create a tag', async () => {
const dto: TagDto = {
uuid: mockTag.uuid,
name: mockTag.name,
category: mockTag.category
? {
Expand Down
3 changes: 3 additions & 0 deletions services/apps/alcs/src/alcs/tag/tag.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('TagCategoryService', () => {

tagRepositoryMock.findOneOrFail.mockResolvedValue(mockTagEntity);
tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity);
tagRepositoryMock.find.mockResolvedValue([]);
tagRepositoryMock.save.mockResolvedValue(mockTagEntity);
tagCategoryRepositoryMock.findOne.mockResolvedValue(mockTagCategoryEntity);
tagCategoryRepositoryMock = module.get(getRepositoryToken(TagCategory));
Expand All @@ -67,6 +68,7 @@ describe('TagCategoryService', () => {

it('should call save when an Tag is updated', async () => {
const payload: TagDto = {
uuid: mockTagEntity.uuid,
name: mockTagEntity.name,
isActive: mockTagEntity.isActive,
category: mockTagCategoryEntity,
Expand All @@ -80,6 +82,7 @@ describe('TagCategoryService', () => {

it('should call save when tag successfully create', async () => {
const payload: TagDto = {
uuid: mockTagEntity.uuid,
name: mockTagEntity.name,
isActive: mockTagEntity.isActive,
category: mockTagCategoryEntity,
Expand Down
2 changes: 1 addition & 1 deletion services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "TZ=UTC jest",
"test:watch": "TZ=UTC jest --watch",
"test:watch": "jest --watch",
"test:cov": "TZ=UTC jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "TZ=UTC jest --config apps/alcs/test/jest-e2e.json",
Expand Down

0 comments on commit 05bee2d

Please sign in to comment.