testauthorization module

This commit is contained in:
Gsk54 2023-01-16 17:15:47 +01:00
parent edcad16e3f
commit 1e5e0f2fbd
2 changed files with 24 additions and 1 deletions

View File

@ -2,7 +2,7 @@ import { QueryHandler } from '@nestjs/cqrs';
import { ValidateAuthorizationQuery } from '../../queries/validate-authorization.query';
@QueryHandler(ValidateAuthorizationQuery)
export class ValidateAuthenticationUseCase {
export class ValidateAuthorizationUseCase {
async execute(validate: ValidateAuthorizationQuery): Promise<boolean> {
return Promise.resolve(validate.action == 'authorized');
}

View File

@ -0,0 +1,23 @@
import { classes } from '@automapper/classes';
import { AutomapperModule } from '@automapper/nestjs';
import { Test, TestingModule } from '@nestjs/testing';
import { ValidateAuthorizationUseCase } from '../../domain/usecases/validate-authorization.usecase';
describe('ValidateAuthorizationUseCase', () => {
let validateAuthorizationUseCase: ValidateAuthorizationUseCase;
beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [AutomapperModule.forRoot({ strategyInitializer: classes() })],
providers: [ValidateAuthorizationUseCase],
}).compile();
validateAuthorizationUseCase = module.get<ValidateAuthorizationUseCase>(
ValidateAuthorizationUseCase,
);
});
it('should be defined', () => {
expect(validateAuthorizationUseCase).toBeDefined();
});
});