fix: harden parseProfilePage class and program extraction
This commit is contained in:
@@ -34,6 +34,26 @@ test('parseProfilePage extracts header fields', () => {
|
||||
assert.strictEqual(p.fullName, 'ADRIAN ALFRED CHIONG BONPIN');
|
||||
assert.strictEqual(p.studentId, '22103625');
|
||||
assert.strictEqual(p.yearLevel, '4');
|
||||
assert.strictEqual(p.studentType, 'CONTINUING');
|
||||
assert.strictEqual(p.program, 'BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY');
|
||||
assert.strictEqual(p.semester, '1ST Semester 2026');
|
||||
});
|
||||
|
||||
test('parseProfilePage matches bold class token with single quotes and extra classes', () => {
|
||||
const html = `
|
||||
<h3><b>BACHELOR OF SCIENCE</b></h3>
|
||||
<table>
|
||||
<tr><td>Full Name</td><td class='bold text-right'>JOHN DOE</td></tr>
|
||||
<tr><td>Student Type</td><td class="bold">CONTINUING</td></tr>
|
||||
</table>
|
||||
`;
|
||||
const p = parseProfilePage(html);
|
||||
assert.strictEqual(p.fullName, 'JOHN DOE');
|
||||
assert.strictEqual(p.studentType, 'CONTINUING');
|
||||
assert.strictEqual(p.program, 'BACHELOR OF SCIENCE');
|
||||
});
|
||||
|
||||
test('parseProfilePage degrades gracefully on empty input', () => {
|
||||
const p = parseProfilePage('');
|
||||
assert.deepStrictEqual(p, {});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user