Add email address generator: 3 styles, 14 domains, inline menu, /email command, tests

This commit is contained in:
kromskii2 committed 2026-09-10 15:15:19 +07:00
1 parent 20c3fb1c06
commit 3b92e317d0
4 files changed
+158 -2

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { generateEmail, EMAIL_DOMAINS } from '../lib/generator.js';
import assert from 'node:assert/strict';
for (const style of ['random', 'pronounceable', 'wordnum']) {
for (const domain of EMAIL_DOMAINS) {
for (let i = 0; i < 200; i++) {
const e = generateEmail({ style, domain, withNumber: i % 2 === 0 });
assert.match(e, /^[a-z0-9][a-z0-9.]*@[a-z.]+$/, 'format for ' + style + '/' + domain + ' -> ' + e);
assert.ok(e.endsWith('@' + domain), 'domain kept: ' + e);
const local = e.split('@')[0];
assert.ok(local.length >= 5, 'local length ok: ' + e);
if (i % 2 === 0) assert.match(local, /\d/, 'has number: ' + e);
}
}
}
console.log('EMAIL SMOKE OK — ' + EMAIL_DOMAINS.length * 3 * 200 + ' адресов валидны');