Skip to content

Commit

Permalink
(#203) adiciona testes
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriqueAmorim20 committed Nov 28, 2023
1 parent 12c48bb commit 68589d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/rotina/rotina.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { Filtering } from '../shared/decorators/filtrate.decorator';
import { Ordering, OrderParams } from '../shared/decorators/ordenate.decorator';
import { OrderParams, Ordering } from '../shared/decorators/ordenate.decorator';
import {
Pagination,
PaginationParams,
Expand All @@ -22,8 +22,8 @@ describe('RotinaController', () => {
categoria: ECategoriaRotina.ALIMENTACAO,
descricao: 'desc',
dataHora: new Date().toISOString() as any,
dataHoraConcluidos: [],
dias: [0, 1],
concluido: false,
};

const rotina = {
Expand Down Expand Up @@ -102,6 +102,7 @@ describe('RotinaController', () => {

describe('findAll', () => {
const filter: IRotinaFilter = {
dataHora: new Date().toISOString(),
idIdoso: 1,
id: 1,
};
Expand All @@ -125,7 +126,7 @@ describe('RotinaController', () => {
jest.spyOn(service, 'findAll').mockReturnValue(Promise.resolve(expected));

const { data, count, pageSize } = await controller.findAll(
filtering,
filtering as any,
pagination,
ordering,
);
Expand Down
12 changes: 10 additions & 2 deletions src/rotina/rotina.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Ordering, OrderParams } from '../shared/decorators/ordenate.decorator';
import { OrderParams, Ordering } from '../shared/decorators/ordenate.decorator';
import {
Pagination,
PaginationParams,
Expand Down Expand Up @@ -109,9 +109,17 @@ describe('RotinaService', () => {
}),
} as any);

const { data, count } = await service.findAll({}, ordering, pagination);
const { data, count } = await service.findAll(
{ dataHora: new Date().toISOString() },
ordering,
pagination,
);
expect(count).toEqual(1);
expect((data as Rotina[])[0]).toEqual(rotina);

const res = await service.findAll({}, ordering, pagination);
expect(res.count).toEqual(1);
expect((res.data as Rotina[])[0]).toEqual(rotina);
});
});
});

0 comments on commit 68589d7

Please sign in to comment.