Skip to content

Commit

Permalink
(#116) aumenta cobertura de teste metrica.service
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelns committed Dec 8, 2023
1 parent f786f4e commit 612e45d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/metrica/metrica.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('MetricaService', () => {
expect(repository.save).toHaveBeenCalledWith(metrica);
});
});

describe('findOne', () => {
it('should find a metrica by id', async () => {
const id = 1;
Expand All @@ -77,4 +78,24 @@ describe('findOne', () => {
});
});

describe('update', () => {
it('should update a metrica by id', async () => {
const id = 1;
const updateMetricaDto: UpdateMetricaDto = {
idIdoso: 3,
categoria: ECategoriaMetrica.PRESSAO_SANGUINEA,
};
const metrica = new Metrica(metricatest);

jest.spyOn(service, 'findOne').mockResolvedValue(metrica);
jest.spyOn(repository, 'save').mockResolvedValue(metrica);

const result = await service.update(id, updateMetricaDto);

expect(result).toEqual(metrica);
expect(service.findOne).toHaveBeenCalledWith(id);
expect(repository.save).toHaveBeenCalledWith(expect.objectContaining(updateMetricaDto));
});
});

});

0 comments on commit 612e45d

Please sign in to comment.