feat(leads): keep gender on leads and form submissions
A lead can carry the same honorific as a person, and a form that asks gender writes it onto the lead. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { applyPersonGenderTitle, splitPersonHonorific } from '@mento/shared';
|
||||
import {
|
||||
applyLeadGenderName,
|
||||
applyPersonGenderTitle,
|
||||
isGenderQuestionLabel,
|
||||
parsePersonGenderAnswer,
|
||||
splitPersonHonorific,
|
||||
} from '@mento/shared';
|
||||
|
||||
describe('عنوان جنسیت در نام شخص', () => {
|
||||
it('ی عربی جناب آقای را مرد میخواند و عنوان معیار را میگذارد', () => {
|
||||
@@ -99,3 +105,38 @@ describe('عنوان جنسیت در نام شخص', () => {
|
||||
assert.equal(`${next.firstName} ${next.lastName}`, 'جناب آقای محمد انتظاری');
|
||||
});
|
||||
});
|
||||
|
||||
describe('جنسیت لید و پاسخ فرم', () => {
|
||||
it('عنوان را روی نام مخاطب میگذارد و عنوان لید را دست نمیزند', () => {
|
||||
const named = applyLeadGenderName({
|
||||
title: 'فروشگاه الماس',
|
||||
contactName: 'مریم رضایی',
|
||||
gender: 'female',
|
||||
showGenderInName: true,
|
||||
});
|
||||
assert.equal(named.title, 'فروشگاه الماس');
|
||||
assert.equal(named.contactName, 'سرکار خانم مریم رضایی');
|
||||
assert.equal(named.gender, 'female');
|
||||
assert.equal(named.showGenderInName, true);
|
||||
});
|
||||
|
||||
it('اگر نام مخاطب خالی باشد عنوان لید پیشوند میگیرد', () => {
|
||||
const named = applyLeadGenderName({
|
||||
title: 'آرش انتظاری',
|
||||
contactName: ' ',
|
||||
gender: 'male',
|
||||
showGenderInName: true,
|
||||
});
|
||||
assert.equal(named.title, 'جناب آقای آرش انتظاری');
|
||||
assert.equal(named.contactName, null);
|
||||
});
|
||||
|
||||
it('پاسخ فرم مرد و زن و هیچکدام را میخواند و برچسب جنسیت را میشناسد', () => {
|
||||
assert.equal(parsePersonGenderAnswer('مرد'), 'male');
|
||||
assert.equal(parsePersonGenderAnswer('خانم'), 'female');
|
||||
assert.equal(parsePersonGenderAnswer('هیچکدام'), 'none');
|
||||
assert.equal(parsePersonGenderAnswer('نمیدانم'), null);
|
||||
assert.equal(isGenderQuestionLabel('جنسیت شما'), true);
|
||||
assert.equal(isGenderQuestionLabel('نام'), false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user