Exercise 2: Testing computeFullPath() — Possible Solution ==================================================================== THE FUNCTION UNDER TEST ------------------------------ // db/pages.ts async function computeFullPath(slug: string, parentId: number | null): Promise { if (!parentId) return slug; const [parent] = await db.select().from(pages).where(eq(pages.id, parentId)); return `${parent.fullPath}/${slug}`; } TEST 1 — NO PARENT ------------------------------ computeFullPath('programming', null) resolves to 'programming' - the early return fires immediately since parentId is null, with no database query issued at all. TEST 2 — WITH A REAL PARENT ------------------------------ Given a page already stored with id: 1 and fullPath: 'programming', computeFullPath('java', 1) queries that row, finds parent.fullPath === 'programming', and resolves to 'programming/java' - the parent's own full path plus the new slug, joined with a single slash. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly traces both branches of computeFullPath() - the no-parent early return and the real-parent database lookup - and correctly shows the resulting full_path value each one produces.