All files / src/modules/notifications notifications.module.ts

100% Statements 11/11
50% Branches 4/8
100% Functions 0/0
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 3411x 11x 11x 11x 11x 11x 11x   11x                                             11x    
import { Module } from '@nestjs/common';
import { BullModule } from '@nestjs/bullmq';
import { PrismaModule } from '@app/modules/prisma/prisma.module';
import { NotificationsController } from './notifications.controller';
import { NotificationsService } from './notifications.service';
import { NotificationsProcessor } from './notifications.processor';
import { NullQueue } from '@app/utils/null-queue';
 
const IS_TEST = process.env.NODE_ENV === 'test' || process.env.TEST_MODE === '1';
 
@Module({
  imports: [
    PrismaModule,
    // Only register queue if not in test mode
    ...(!IS_TEST
      ? [
          BullModule.registerQueue({
            name: 'notifications',
          }),
        ]
      : []),
  ],
  controllers: [NotificationsController],
  providers: [
    NotificationsService,
    ...(!IS_TEST ? [NotificationsProcessor] : []),
    // Provide a NullQueue mock in test mode
    ...(IS_TEST ? [{ provide: 'BullQueue_notifications', useClass: NullQueue }] : []),
  ],
  exports: [NotificationsService],
})
export class NotificationsModule {}