feat(professors,sms): merge professor with users, add existing user link, professor portal endpoint, and SMS bypass list
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { normalizePhoneForBypass } = require('./messagingFlags');
|
||||
|
||||
test('SMS Bypass Numbers Utilities', async (t) => {
|
||||
await t.test('normalizePhoneForBypass handles various phone formats and Persian digits', () => {
|
||||
assert.equal(normalizePhoneForBypass('۰۹۱۲۳۴۵۶۷۸۹'), '09123456789');
|
||||
assert.equal(normalizePhoneForBypass('+989123456789'), '09123456789');
|
||||
assert.equal(normalizePhoneForBypass('989123456789'), '09123456789');
|
||||
assert.equal(normalizePhoneForBypass('9123456789'), '09123456789');
|
||||
assert.equal(normalizePhoneForBypass('0912-345-6789'), '09123456789');
|
||||
assert.equal(normalizePhoneForBypass(''), '');
|
||||
assert.equal(normalizePhoneForBypass(null), '');
|
||||
});
|
||||
|
||||
await t.test('bypass list matches normalized phone numbers correctly', () => {
|
||||
const bypassList = [
|
||||
{ phoneNumber: '09123456789', label: 'مدیریت', isActive: true },
|
||||
{ phoneNumber: '09351112233', label: 'پشتیبان غیرفعال', isActive: false }
|
||||
];
|
||||
|
||||
const isMatch = (targetPhone) => {
|
||||
const normalized = normalizePhoneForBypass(targetPhone);
|
||||
return bypassList.some(
|
||||
(item) => item.isActive !== false && normalizePhoneForBypass(item.phoneNumber) === normalized
|
||||
);
|
||||
};
|
||||
|
||||
assert.equal(isMatch('09123456789'), true);
|
||||
assert.equal(isMatch('+989123456789'), true);
|
||||
assert.equal(isMatch('۰۹۱۲۳۴۵۶۷۸۹'), true);
|
||||
assert.equal(isMatch('09351112233'), false); // Inactive
|
||||
assert.equal(isMatch('09100000000'), false); // Not in list
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user