Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/test-crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,22 @@ const mockFetch = async (url, options) => {
assert.ok(demoResult.findings.length >= 2);
assert.ok(demoResult.improvedDraft.title.includes('Matrix'));

// Test 4: Error Path Test for course fetch failure
const mockFailedFetch = async (url) => {
return {
ok: false,
status: 404
};
};

let errorThrown = false;
try {
await crawlCanvasCourse('https://canvas.instructure.com', 'invalid-id', mockFailedFetch);
} catch (err) {
errorThrown = true;
assert.strictEqual(err.message, 'Failed to fetch Canvas course info (404)');
}
assert.ok(errorThrown, 'Expected an error to be thrown for failed fetch');

console.log('βœ… Task 2 Canvas crawler tests passed.');
})();
Loading