37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { validateEmailContent } from '../services/content-validator.service';
|
|
|
|
const VALID_BODY =
|
|
'Hi there, I wanted to follow up on our conversation about streamlining operations for your team. ' +
|
|
'We have been reviewing options that could reduce manual coordination and improve response times across departments. ' +
|
|
'Would you be open to a short call next week to discuss priorities and next steps?';
|
|
|
|
describe('content-validator.service', () => {
|
|
it('accepts realistic B2B content', () => {
|
|
const result = validateEmailContent('Following up on our discussion', VALID_BODY);
|
|
assert.equal(result.valid, true);
|
|
assert.equal(result.errors.length, 0);
|
|
});
|
|
|
|
it('rejects bracket placeholders', () => {
|
|
const result = validateEmailContent('Hello', 'Dear [Director name], please review this.');
|
|
assert.equal(result.valid, false);
|
|
assert.ok(result.errors.some((e) => e.includes('placeholder')));
|
|
});
|
|
|
|
it('rejects mustache placeholders', () => {
|
|
const result = validateEmailContent('Hello', 'Dear {{company}}, thanks for your time.');
|
|
assert.equal(result.valid, false);
|
|
});
|
|
|
|
it('rejects tier-1 spam phrases', () => {
|
|
const result = validateEmailContent('Act now', VALID_BODY);
|
|
assert.equal(result.valid, false);
|
|
});
|
|
|
|
it('rejects URLs in body', () => {
|
|
const result = validateEmailContent('Hello', 'Please see https://example.com for details.');
|
|
assert.equal(result.valid, false);
|
|
});
|
|
});
|