test(web): add unit tests for pure helper functions (#2454)

* test(web): add unit tests for pure helper functions

Add vitest configuration and tests for:
- relativeTime: time formatting (just now, minutes, hours, days, months, years)
- lastPageFromLink: GitHub Link header pagination parsing

These are the first tests for the web frontend. The test framework
(vitest) was already in package.json but had no config or test files.

* test(web): exercise real GitHub helpers

---------

Co-authored-by: Hu Qiantao <huqiantao@HudeMacBook-Air.local>
Co-authored-by: Hunter B <hmbown@gmail.com>
This commit is contained in:
HUQIANTAO
2026-06-01 01:21:09 +08:00
committed by GitHub
parent 311333d887
commit dfeedca524
5 changed files with 1651 additions and 14 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ async function contributorCount(res: Response): Promise<number> {
return MIN_KNOWN_CONTRIBUTORS;
}
function lastPageFromLink(link: string | null): number | undefined {
export function lastPageFromLink(link: string | null): number | undefined {
if (!link) return undefined;
for (const part of link.split(",")) {