40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { parseStudyLoadTable } = require('../parsers.js');
|
|
const { parseProfilePage } = require('../parsers.js');
|
|
|
|
const fixture = fs.readFileSync(path.join(__dirname, 'fixtures', 'study-load-table.html'), 'utf8');
|
|
const profileFixture = fs.readFileSync(path.join(__dirname, 'fixtures', 'profile.html'), 'utf8');
|
|
|
|
test('parseStudyLoadTable extracts all course rows', () => {
|
|
const rows = parseStudyLoadTable(fixture);
|
|
assert.strictEqual(rows.length, 5);
|
|
});
|
|
|
|
test('parseStudyLoadTable maps columns correctly', () => {
|
|
const rows = parseStudyLoadTable(fixture);
|
|
const first = rows[0];
|
|
assert.strictEqual(first.group, '1');
|
|
assert.strictEqual(first.courseCode, 'CS 5105');
|
|
assert.strictEqual(first.units, '3.00');
|
|
assert.strictEqual(first.status, 'DISSOLVED');
|
|
assert.ok(first.schedule.includes('F 01:30 PM'));
|
|
});
|
|
|
|
test('parseStudyLoadTable handles empty faculty', () => {
|
|
const rows = parseStudyLoadTable(fixture);
|
|
const it4102 = rows.find(r => r.courseCode === 'IT 4102N');
|
|
assert.strictEqual(it4102.faculty, '');
|
|
});
|
|
|
|
test('parseProfilePage extracts header fields', () => {
|
|
const p = parseProfilePage(profileFixture);
|
|
assert.strictEqual(p.fullName, 'ADRIAN ALFRED CHIONG BONPIN');
|
|
assert.strictEqual(p.studentId, '22103625');
|
|
assert.strictEqual(p.yearLevel, '4');
|
|
assert.strictEqual(p.program, 'BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY');
|
|
assert.strictEqual(p.semester, '1ST Semester 2026');
|
|
});
|