import { expect } from 'chai' ; import { Reflector } from '@nestjs/core' ; import { UserStatus } from '@energyweb/origin-backend-core' ; import { ExecutionContext } from '@nestjs/common' ; import { ActiveUserGuard } from '../..' ; describe ( 'DeviceTypeService tests' , ( ) => { let guard ; const reflector = { } as Reflector ; before ( ( ) => { guard = new ActiveUserGuard ( reflector ) ; } ) ; it ( 'Active user should pass guard' , ( ) => { const context = ( { switchToHttp : ( ) => { return { getRequest : ( ) => { return { user : { status : UserStatus . Active } } ; } } ; } } as unknown ) as ExecutionContext ; expect ( guard . canActivate ( context ) ) . true ; } ) ; it ( 'Inactive user should not pass guard' , ( ) => { const context = ( { switchToHttp : ( ) => { return { getRequest : ( ) => { return { user : { status : UserStatus . Suspended } } ; } } ; } } as unknown ) as ExecutionContext ; expect ( guard . canActivate . bind ( context ) ) . to . throw ; } ) ; } ) ;