All files / src/platform/notifications/providers mock-other.providers.ts

0% Statements 0/19
100% Branches 0/0
0% Functions 0/3
0% Lines 0/19

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47                                                                                             
import { Logger } from '@nestjs/common';
import { NotificationChannelProvider } from '../notification-provider.interface';
 
export class MockSmsProvider implements NotificationChannelProvider {
  readonly channel = 'SMS';
  readonly name = 'MockTwilioSms';
  private readonly logger = new Logger(MockSmsProvider.name);
 
  async send(to: string, subject: string, body: string) {
    this.logger.log(`[SMS DISPATCH] To: ${to} | Body: ${body}`);
    return {
      success: true,
      messageId: `sms-${Math.random().toString(36).substr(2, 9)}`,
    };
  }
}
 
export class MockWhatsappProvider implements NotificationChannelProvider {
  readonly channel = 'WHATSAPP';
  readonly name = 'MockTwilioWhatsApp';
  private readonly logger = new Logger(MockWhatsappProvider.name);
 
  async send(to: string, subject: string, body: string) {
    this.logger.log(`[WHATSAPP DISPATCH] To: ${to} | Body: ${body}`);
    return {
      success: true,
      messageId: `wa-${Math.random().toString(36).substr(2, 9)}`,
    };
  }
}
 
export class MockPushProvider implements NotificationChannelProvider {
  readonly channel = 'PUSH';
  readonly name = 'MockFirebasePush';
  private readonly logger = new Logger(MockPushProvider.name);
 
  async send(to: string, subject: string, body: string, metadata?: any) {
    this.logger.log(
      `[PUSH DISPATCH] To (Token): ${to} | Title: ${subject} | Body: ${body}`,
    );
    return {
      success: true,
      messageId: `push-${Math.random().toString(36).substr(2, 9)}`,
    };
  }
}