← back to Ventura Claw Leads
tests/verticals.test.js
49 lines
// Verticals registry — single source of truth for the 8-vertical green list.
// Constraint enforced at the DB level (CHECK on businesses.vertical) — these
// tests assert the registry stays aligned with that enum.
const test = require('node:test');
const assert = require('node:assert/strict');
const v = require('../lib/verticals');
const ALLOWED = ['food','beauty','retail','fitness','pet_services','auto_detail','cleaning','creative'];
const REGULATED_FORBIDDEN = ['medical','legal','financial','real_estate','realestate','contracting','contractors','doctors','lawyers','dentists','therapists','accountants','insurance'];
test('VERTICALS has exactly 8 entries', () => {
assert.equal(v.VERTICALS.length, 8);
});
test('every VERTICALS entry has key/label/blurb/icon', () => {
for (const entry of v.VERTICALS) {
assert.ok(entry.key);
assert.ok(entry.label);
assert.ok(entry.blurb);
assert.ok(entry.icon);
}
});
test('VERTICALS keys exactly match the green list', () => {
const keys = v.VERTICALS.map(x => x.key).sort();
assert.deepEqual(keys, ALLOWED.slice().sort());
});
test('NO regulated-vertical key is present', () => {
const keys = v.VERTICALS.map(x => x.key);
for (const forbidden of REGULATED_FORBIDDEN) {
assert.equal(keys.includes(forbidden), false, `regulated key "${forbidden}" must not appear`);
}
});
test('BY_KEY index is consistent with VERTICALS', () => {
for (const entry of v.VERTICALS) {
assert.equal(v.BY_KEY[entry.key], entry);
}
});
test('label() and icon() helpers', () => {
assert.equal(v.label('food'), 'Food & drink');
assert.equal(v.label('unknown'), 'unknown');
assert.ok(v.icon('food'));
assert.equal(v.icon('unknown'), '•');
});