testauthorization module
This commit is contained in:
		
							parent
							
								
									edcad16e3f
								
							
						
					
					
						commit
						1e5e0f2fbd
					
				| 
						 | 
				
			
			@ -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');
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
		Reference in New Issue