Files
portfolio-next/test/site/course-search.test.ts
T
Lucas WintherandClaude Opus 5.5 974b3eb0df feat(work): CV-first work page, six proud projects, record and courses (spec 009)
- CV header with highlights and keeping-up summary replaces the intro and Now strip
- "Projects I'm proudest of": up to six featured panels; screenshots muted until hover
- "Also made" list; searching it also lists matching courses
- Record section: recognition & volunteering, courses by topic
- /work/learning/: searchable course list (plain script), in the sitemap
- Top bar: Projects, Record, Writing, CV; no Bluesky link in the work footer
- Highlights: only the placement takes the accent (owner, after the preview)

Owner looked at the rendered preview on 2026-11-12 before this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 10:44:46 +01:00

30 lines
1.4 KiB
TypeScript

import { expect, test } from 'bun:test';
import { courseStrip, matchCountText, type ListCourse } from '../../src/site/components/work/course-search.ts';
const c = (title: string, completed: string, over: Partial<ListCourse> = {}): ListCourse => ({
title, provider: 'Prov', kind: 'course', topic: 'Java', completed, minutes: 30, certificate: false, keywords: [], ...over,
});
const all = [
c('Java A', '2025-01-01'), c('Java B', '2025-03-01', { certificate: true }), c('Java C', '2025-02-01', { kind: 'lab' }),
c('Java D', '2025-05-01'), c('Java E', '2025-04-01'), c('Java F', '2025-06-01'), c('Other', '2025-07-01', { topic: 'Cloud' }),
];
test('courseStrip: nothing for an empty query', () => {
expect(courseStrip(all, ' ')).toEqual({ shown: [], more: 0, count: 0, href: '' });
});
test('courseStrip: newest first, at most five, the rest counted, link carries the query', () => {
const s = courseStrip(all, 'java');
expect(s.count).toBe(6);
expect(s.shown.map((x) => x.title)).toEqual(['Java F', 'Java D', 'Java E', 'Java B', 'Java C']);
expect(s.more).toBe(1);
expect(s.href).toBe('/work/learning/?q=java');
expect(courseStrip(all, 'a b&c').href).toBe('/work/learning/?q=a%20b%26c');
});
test('matchCountText', () => {
expect(matchCountText(1, 5)).toBe('1 project · 5 courses match');
expect(matchCountText(0, 1)).toBe('0 projects · 1 course matches');
expect(matchCountText(2, 0)).toBe('');
});