Skip to content

Comments

Add unit tests for frontend utilities#944

Merged
rchlfryn merged 10 commits intomainfrom
utility-tests
Feb 16, 2026
Merged

Add unit tests for frontend utilities#944
rchlfryn merged 10 commits intomainfrom
utility-tests

Conversation

@rchlfryn
Copy link
Collaborator

@rchlfryn rchlfryn commented Feb 15, 2026

Description

Tests for relationships, validation (slug, phone, zip, URL), formatting (authors, initials, relative time), and string/path utilities (kebab-case, normalizePath, isAbsoluteUrl, extractID).

Related Issues

Part of building out our test suite #519

Key Changes

  • Added 14 new client-side utility test files covering extractID, formatAuthors, getAuthorInitials, getRelativeTime, handleReferenceURL, isAbsoluteUrl, normalizePath, phoneValidation, relationships, toKebabCase, validateSlug, validateUrl, and zipValidation
  • Created shared __tests__/builders.ts with factory helpers (buildBuiltInPage, buildPage, buildPost, buildTenant) to construct type-safe test data without type assertions
  • Removed all as type assertions and eslint-disable comments from test files, using builders and jest.mocked() instead
  • Reorganized test files into components/ and utilities/ subdirectories under __tests__/client/

How to test

pnpm test

Future enhancements / Questions

  • The Jest config testMatch patterns (__tests__/client/* and __tests__/server/*) only match one level deep — tests in subdirectories like utilities/ and components/ won't be discovered until the globs are updated to __tests__/client/**/*

Tests for relationships, validation (slug, phone, zip, URL),
formatting (authors, initials, relative time), and string/path
utilities (kebab-case, normalizePath, isAbsoluteUrl, extractID).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

Preview deployment: https://utility-tests.preview.avy-fx.org

@rchlfryn rchlfryn marked this pull request as ready for review February 16, 2026 17:29
@rchlfryn rchlfryn self-assigned this Feb 16, 2026
@rchlfryn rchlfryn changed the title Add unit tests for core frontend utilities Add unit tests for frontend utilities Feb 16, 2026
@rchlfryn rchlfryn added this pull request to the merge queue Feb 16, 2026
Merged via the queue into main with commit 0343895 Feb 16, 2026
8 checks passed
@rchlfryn rchlfryn deleted the utility-tests branch February 16, 2026 21:07
@github-actions
Copy link

🚀 This is included in version v1.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant