generated from HenriqueAmorim20/GEROcuidadoAPITemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#116-CRUD-metricas
- Loading branch information
Showing
15 changed files
with
1,375 additions
and
1,120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Deploy | |
|
||
on: | ||
push: | ||
branches: ['main'] | ||
branches: ['develop'] | ||
tags: ['v*.*.*'] | ||
|
||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<testExecutions version="1"> | ||
<file path="src/rotina/rotina.service.spec.ts"> | ||
<testCase name="RotinaService should be defined" duration="91" /> | ||
<testCase name="RotinaService should create Rotina" duration="40" /> | ||
<testCase name="RotinaService should find Rotina" duration="35" /> | ||
<testCase name="RotinaService should remove Rotina" duration="31" /> | ||
<testCase name="RotinaService should update Rotina" duration="47" /> | ||
<testCase name="RotinaService findAll should findAll Rotina" duration="48" /> | ||
<testCase name="RotinaService findAll should findAllToCron Rotina" duration="45" /> | ||
</file> | ||
<file path="src/cron/cron.service.spec.ts"> | ||
<testCase name="CronService should be defined" duration="781" /> | ||
<testCase name="CronService should call rotina service" duration="334" /> | ||
</file> | ||
<file path="src/rotina/rotina.controller.spec.ts"> | ||
<testCase name="RotinaController should be defined" duration="79" /> | ||
<testCase name="RotinaController should create Idoso" duration="39" /> | ||
<testCase name="RotinaController should find Idoso" duration="27" /> | ||
<testCase name="RotinaController should remove Idoso" duration="20" /> | ||
<testCase name="RotinaController should update Idoso" duration="24" /> | ||
<testCase name="RotinaController findAll should findAll Rotina" duration="22" /> | ||
</file> | ||
<file path="src/idoso/idoso.controller.spec.ts"> | ||
<testCase name="IdosoController should be defined" duration="74" /> | ||
<testCase name="IdosoController should create Idoso" duration="35" /> | ||
<testCase name="IdosoController should find Idoso" duration="27" /> | ||
<testCase name="IdosoController should remove Idoso" duration="28" /> | ||
<testCase name="IdosoController should update Idoso" duration="40" /> | ||
<testCase name="IdosoController findAll should findAll Idoso" duration="47" /> | ||
</file> | ||
<file path="src/idoso/idoso.service.spec.ts"> | ||
<testCase name="IdosoService should be defined" duration="83" /> | ||
<testCase name="IdosoService should create Idoso" duration="188" /> | ||
<testCase name="IdosoService should find Idoso" duration="61" /> | ||
<testCase name="IdosoService should remove Idoso" duration="28" /> | ||
<testCase name="IdosoService should update Idoso" duration="28" /> | ||
<testCase name="IdosoService should update Idoso with photo" duration="27" /> | ||
<testCase name="IdosoService findAll should findAll Idoso" duration="56" /> | ||
</file> | ||
<file path="src/config/db/db.service.spec.ts"> | ||
<testCase name="DbService should be defined" duration="74" /> | ||
<testCase name="DbService should return db config development" duration="49" /> | ||
<testCase name="DbService should return db config production" duration="38" /> | ||
</file> | ||
<file path="src/autenticacao.guard.spec.ts"> | ||
<testCase name="AutenticacaoGuard should be defined" duration="86" /> | ||
<testCase name="AutenticacaoGuard should pass if route is public" duration="33" /> | ||
<testCase name="AutenticacaoGuard should pass if authentication is successful" duration="40" /> | ||
<testCase name="AutenticacaoGuard should not pass if authentication is unsuccessful" duration="34" /> | ||
</file> | ||
<file path="src/shared/validators/id.validator.spec.ts"> | ||
<testCase name="HttpResponse should be defined" duration="10" /> | ||
</file> | ||
<file path="src/shared/decorators/paginate.decorator.spec.ts"> | ||
<testCase name="Pagination should be defined" duration="10" /> | ||
<testCase name="Pagination should be Paginate" duration="10" /> | ||
<testCase name="Pagination should be Paginate not limit" duration="2" /> | ||
<testCase name="Pagination should be Paginate not offset" duration="3" /> | ||
</file> | ||
<file path="src/shared/decorators/ordenate.decorator.spec.ts"> | ||
<testCase name="Pagination should be defined" duration="10" /> | ||
<testCase name="Pagination should be Paginate" duration="8" /> | ||
<testCase name="Pagination should be Paginate not limit" duration="6" /> | ||
<testCase name="Pagination should be Paginate not offset" duration="3" /> | ||
<testCase name="Ordenate should return default object if there is no JSON" duration="4" /> | ||
<testCase name="Ordenate should return OrderParams object with values for order" duration="3" /> | ||
<testCase name="Ordenate should return default values when obj has empty props" duration="2" /> | ||
<testCase name="Ordenate should be Ordenate using factory" duration="2" /> | ||
</file> | ||
<file path="src/shared/decorators/public-route.spec.ts"> | ||
<testCase name="Pagination should be defined" duration="10" /> | ||
</file> | ||
<file path="src/shared/decorators/filtrate-string.spec.ts"> | ||
<testCase name="Pagination should be defined" duration="14" /> | ||
<testCase name="Pagination should be Paginate" duration="9" /> | ||
<testCase name="Pagination should be Paginate not limit" duration="6" /> | ||
<testCase name="Pagination should be Paginate not offset" duration="3" /> | ||
<testCase name="FiltrateString should return empty object for filter" duration="5" /> | ||
<testCase name="FiltrateString should return TestFilterProps object with values for filter" duration="2" /> | ||
<testCase name="FiltrateString should be FiltrateString using factory" duration="3" /> | ||
</file> | ||
<file path="src/shared/interceptors/data-transform.interceptor.spec.ts"> | ||
<testCase name="DataTransformInterceptor should be defined" duration="10" /> | ||
<testCase name="DataTransformInterceptor should be intercept t1" duration="16" /> | ||
<testCase name="DataTransformInterceptor should be intercept should formatData with message" duration="2" /> | ||
<testCase name="DataTransformInterceptor should be intercept should formatData with no message" duration="2" /> | ||
<testCase name="DataTransformInterceptor should be intercept should formatData with Paginate" duration="3" /> | ||
</file> | ||
<file path="src/shared/decorators/filtrate.decorator.spec.ts"> | ||
<testCase name="Pagination should be defined" duration="11" /> | ||
<testCase name="Pagination should be Paginate" duration="7" /> | ||
<testCase name="Pagination should be Paginate not limit" duration="5" /> | ||
<testCase name="Pagination should be Paginate not offset" duration="2" /> | ||
<testCase name="Filtrate should return empty object for filter" duration="4" /> | ||
<testCase name="Filtrate should return TestFilterProps object with values for filter" duration="2" /> | ||
<testCase name="Filtrate should be Filtrate using factory" duration="2" /> | ||
</file> | ||
<file path="src/shared/filters/all-exceptions.filter.spec.ts"> | ||
<testCase name="AllExceptionsFilter should be defined" duration="10" /> | ||
<testCase name="AllExceptionsFilter should be catch" duration="8" /> | ||
<testCase name="AllExceptionsFilter should be not exception to class-validator" duration="3" /> | ||
<testCase name="AllExceptionsFilter should be not exception only message" duration="3" /> | ||
</file> | ||
<file path="src/shared/filters/model-not-found.exception-filter.spec.ts"> | ||
<testCase name="ModelNotFoundExceptionFilter should be defined" duration="10" /> | ||
<testCase name="ModelNotFoundExceptionFilter should be catch" duration="8" /> | ||
</file> | ||
<file path="src/shared/classes/http-response.spec.ts"> | ||
<testCase name="HttpResponse should be defined" duration="8" /> | ||
<testCase name="HttpResponse should create message with payload text" duration="6" /> | ||
<testCase name="HttpResponse should create message with success text" duration="2" /> | ||
<testCase name="HttpResponse should create message with updated text" duration="2" /> | ||
<testCase name="HttpResponse should create message with deleted text" duration="2" /> | ||
</file> | ||
<file path="src/shared/helpers/string-helpers.spec.ts"> | ||
<testCase name="String Helpers should be regex" duration="9" /> | ||
</file> | ||
<file path="src/shared/helpers/sql-query-helper.spec.ts"> | ||
<testCase name="Where Clause STRING should return empty string if value is undefined" duration="9" /> | ||
<testCase name="Where Clause STRING should return empty string if value has no length" duration="2" /> | ||
<testCase name="Where Clause STRING should return where string based on given value and tableColumn" duration="1" /> | ||
<testCase name="Where Clause NUMBER should return empty string if value is undefined" duration="1" /> | ||
<testCase name="Where Clause NUMBER should return where string based on given value and tableColumn" duration="3" /> | ||
<testCase name="Where Clause BOOLEAN should return empty string if value is undefined" duration="1" /> | ||
<testCase name="Where Clause BOOLEAN should return empty string if value is higher than 1" duration="1" /> | ||
<testCase name="Where Clause BOOLEAN should return where string based on given value and tableColumn" duration="1" /> | ||
<testCase name="Where Clause ARRAY NUMBER should return empty string if value is undefined" duration="3" /> | ||
<testCase name="Where Clause ARRAY NUMBER should return where string if value is number" duration="3" /> | ||
<testCase name="Where Clause ARRAY NUMBER should return where string if value is number array" duration="3" /> | ||
</file> | ||
<file path="src/shared/helpers/buffer-to-image.spec.ts"> | ||
<testCase name="Buffer to image bufferToBase64 should be bufferToBase64 a image" duration="14" /> | ||
<testCase name="Buffer to image bufferToBase64 should getImageUri" duration="3" /> | ||
<testCase name="Buffer to image bufferToBase64 should be bufferToBase64 a empty if null" duration="3" /> | ||
<testCase name="Buffer to image bufferToBase64 should be bufferToBase64 a empty if not image" duration="3" /> | ||
<testCase name="Buffer to image isBase64 should be false" duration="3" /> | ||
<testCase name="Buffer to image isBase64 should be true" duration="4" /> | ||
<testCase name="Buffer to image isBase64Image should be false" duration="2" /> | ||
<testCase name="Buffer to image isBase64Image should be true" duration="3" /> | ||
</file> | ||
<file path="src/shared/helpers/commons.spec.ts"> | ||
<testCase name="Helper deve criar um hash com tamanho default" duration="13" /> | ||
<testCase name="Helper should be return if its nill for undefined" duration="4" /> | ||
<testCase name="Helper should be return if its nill for null" duration="1" /> | ||
<testCase name="Helper should be isJsonObject to be true" duration="3" /> | ||
<testCase name="Helper should be isJsonObject to be false" duration="2" /> | ||
<testCase name="Helper should be isJsonObject to be false in not parse" duration="1" /> | ||
</file> | ||
</testExecutions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { HttpModule } from '@nestjs/axios'; | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { Rotina } from '../rotina/entities/rotina.entity'; | ||
import { RotinaService } from '../rotina/rotina.service'; | ||
import { CronService } from './cron.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Rotina]), HttpModule], | ||
providers: [CronService, RotinaService, Repository], | ||
}) | ||
export class CronModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { HttpModule, HttpService } from '@nestjs/axios'; | ||
import { SchedulerRegistry } from '@nestjs/schedule'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { getRepositoryToken } from '@nestjs/typeorm'; | ||
import { of } from 'rxjs'; | ||
import { ECategoriaRotina } from '../rotina/classes/categoria-rotina.enum'; | ||
import { Rotina } from '../rotina/entities/rotina.entity'; | ||
import { RotinaService } from '../rotina/rotina.service'; | ||
import { AppModule } from './../app.module'; | ||
import { CronService } from './cron.service'; | ||
|
||
jest.mock('cron', () => { | ||
const mScheduleJob = { start: jest.fn(), stop: jest.fn() }; | ||
const mCronJob = jest.fn(() => mScheduleJob); | ||
return { CronJob: mCronJob }; | ||
}); | ||
|
||
describe('CronService', () => { | ||
let service: CronService; | ||
let rotinaService: RotinaService; | ||
let schedulerRegistry: SchedulerRegistry; | ||
let httpService: HttpService; | ||
|
||
const rotina = { | ||
idIdoso: 1, | ||
titulo: 'titulo', | ||
categoria: ECategoriaRotina.ALIMENTACAO, | ||
descricao: 'desc', | ||
dataHora: new Date().toISOString() as any, | ||
dataHoraConcluidos: [], | ||
dias: [0, 1], | ||
token: '', | ||
notificacao: false, | ||
id: 1, | ||
}; | ||
|
||
const mockRepository = { | ||
createQueryBuilder: jest.fn(() => ({ | ||
where: jest.fn().mockReturnThis(), | ||
getMany: jest.fn(), | ||
})), | ||
}; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule, HttpModule], | ||
providers: [ | ||
{ | ||
provide: RotinaService, | ||
useValue: { | ||
findAllToCron() { | ||
return of([rotina]); | ||
}, | ||
}, | ||
}, | ||
{ | ||
provide: getRepositoryToken(Rotina), | ||
useValue: mockRepository, | ||
}, | ||
CronService, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<CronService>(CronService); | ||
rotinaService = module.get<RotinaService>(RotinaService); | ||
httpService = module.get<HttpService>(HttpService); | ||
schedulerRegistry = module.get<SchedulerRegistry>(SchedulerRegistry); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it('should call rotina service', async () => { | ||
service.onModuleInit(); | ||
|
||
const spy = jest | ||
.spyOn(rotinaService, 'findAllToCron') | ||
.mockReturnValue(Promise.resolve([rotina])); | ||
|
||
const spyHttp = jest | ||
.spyOn(httpService, 'post') | ||
.mockReturnValue(of(true as any)); | ||
|
||
await service.cronRotinas(); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(spyHttp).toHaveBeenCalledTimes(1); | ||
schedulerRegistry.deleteCronJob('cronRotinas'); | ||
}); | ||
}); |
Oops, something went wrong.