-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-name-enhanced.ts
More file actions
28 lines (25 loc) · 893 Bytes
/
test-name-enhanced.ts
File metadata and controls
28 lines (25 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { NameEnhanced } from './client/src/lib/NameEnhanced';
const testCases = [
'John Doe (he/him) (Ph.D.)',
'Jane Smith (she/her) (MBA)',
'Dr. Bob (they/them) (MD)',
'Alice Wong (Ph.D.)',
'John "Johnny" Doe (he/him)',
];
console.log('Testing NameEnhanced with pronouns and credentials:\n');
testCases.forEach(testName => {
try {
const name = new NameEnhanced(testName);
console.log(`Input: "${testName}"`);
console.log(` Valid: ${name.isValid}`);
console.log(` Full: "${name.full}"`);
console.log(` First: "${name.firstName}"`);
console.log(` Last: "${name.lastName}"`);
if (name.nickname) console.log(` Nickname: "${name.nickname}"`);
if (!name.isValid) console.log(` Reason: ${name.invalidReason}`);
console.log('');
} catch (e: any) {
console.log(`Input: "${testName}"`);
console.log(` ERROR: ${e.message}\n`);
}
});