Chat-only commands reset voicemail mailbox and voice portal passcodes via telephony_config_write, with extension lookup and unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
// tests/resetVmPin.generatePin.test.js
|
|
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { generatePin } from '../services/voicePin/generatePin.js';
|
|
|
|
test('generatePin returns fixed 6-digit PIN by default', () => {
|
|
const pin = generatePin();
|
|
assert.match(pin, /^\d{6}$/);
|
|
});
|
|
|
|
test('generatePin respects min and max length from rules', () => {
|
|
const pin = generatePin({ rules: { length: { min: 4, max: 4 } } });
|
|
assert.match(pin, /^\d{4}$/);
|
|
});
|
|
|
|
test('generatePin avoids all-same-digit when disallowRepeating is set', () => {
|
|
for (let i = 0; i < 20; i += 1) {
|
|
const pin = generatePin({
|
|
minLength: 4,
|
|
maxLength: 4,
|
|
rules: { disallowRepeating: true },
|
|
});
|
|
assert.notEqual(/^(\d)\1+$/.test(pin), true);
|
|
}
|
|
});
|
|
|
|
test('generatePin avoids matching extension when disallowSameAsExtension is set', () => {
|
|
for (let i = 0; i < 20; i += 1) {
|
|
const pin = generatePin({
|
|
minLength: 5,
|
|
maxLength: 5,
|
|
extension: '12345',
|
|
rules: { disallowSameAsExtension: true },
|
|
});
|
|
assert.notEqual(pin, '12345');
|
|
}
|
|
});
|