Skip to content

Commit

Permalink
refactor(mail.service): changes to use env var instead of const
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Jul 14, 2021
1 parent 9a7ca5e commit 876e096
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {

import { generateDefaultField } from 'tests/unit/backend/helpers/generate-form-data'

import { SMS_VERIFICATION_LIMIT } from '../../../../../shared/util/verification'
import { smsConfig } from '../../../../config/features/sms.config'
import * as SmsService from '../../../../services/sms/sms.service'
import {
FormNotFoundError,
Expand Down Expand Up @@ -2266,7 +2266,7 @@ describe('admin-form.service', () => {

it('should return the form when admin is under the limit', async () => {
// Arrange
countSpy.mockReturnValueOnce(okAsync(SMS_VERIFICATION_LIMIT))
countSpy.mockReturnValueOnce(okAsync(smsConfig.smsVerificationLimit))

// Act
const actual = await shouldUpdateFormField(
Expand Down Expand Up @@ -2320,7 +2320,7 @@ describe('admin-form.service', () => {

it('should return sms retrieval error when sms limit exceeded and admin is attempting to toggle sms verification for mobile field on', async () => {
// Arrange
countSpy.mockReturnValueOnce(okAsync(SMS_VERIFICATION_LIMIT + 1))
countSpy.mockReturnValueOnce(okAsync(smsConfig.smsVerificationLimit + 1))

// Act
const actual = await shouldUpdateFormField(
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/verification/verification.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { StatusCodes } from 'http-status-codes'

import {
HASH_EXPIRE_AFTER_SECONDS,
SMS_VERIFICATION_LIMIT,
VERIFIED_FIELDTYPES,
WAIT_FOR_OTP_SECONDS,
WAIT_FOR_OTP_TOLERANCE_SECONDS,
Expand All @@ -12,6 +11,7 @@ import {
IVerificationSchema,
MapRouteError,
} from '../../../types'
import { smsConfig } from '../../config/features/sms.config'
import { createLoggerWithLabel } from '../../config/logger'
import { MailSendError } from '../../services/mail/mail.errors'
import { InvalidNumberError, SmsSendError } from '../../services/sms/sms.errors'
Expand Down Expand Up @@ -213,5 +213,5 @@ export const mapRouteError: MapRouteError = (
}

export const hasAdminExceededFreeSmsLimit = (smsCount: number): boolean => {
return smsCount > SMS_VERIFICATION_LIMIT
return smsCount > smsConfig.smsVerificationLimit
}
2 changes: 0 additions & 2 deletions src/shared/util/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ export enum VfnErrors {
TransactionNotFound = 'TRANSACTION_NOT_FOUND',
InvalidMobileNumber = 'INVALID_MOBILE_NUMBER',
}

export const SMS_VERIFICATION_LIMIT = 10000

0 comments on commit 876e096

Please sign in to comment.