fix: harden parseProfilePage class and program extraction

This commit is contained in:
2026-08-18 15:30:49 +08:00
parent 3c409ea048
commit 94d9b7a879
2 changed files with 24 additions and 2 deletions
+20
View File
@@ -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, {});
});