Skip to content

test: add unit tests for HexDump and useFileBinaryPreviewQuery#351

Merged
allison-truhlar merged 1 commit intomainfrom
mkitti-binary-file-display-tests
Apr 10, 2026
Merged

test: add unit tests for HexDump and useFileBinaryPreviewQuery#351
allison-truhlar merged 1 commit intomainfrom
mkitti-binary-file-display-tests

Conversation

@mkitti
Copy link
Copy Markdown
Contributor

@mkitti mkitti commented Apr 9, 2026

Summary

Adds unit tests for the two new items introduced in the binary file display feature:

  • hexDump.test.tsx (11 tests) — covers the HexDump component:

    • Correct offset, hex, and ASCII column formatting
    • Uppercase hex for offsets and byte values
    • Byte count display when not truncated
    • Truncation message when totalFileSize > bytes.length
    • Non-printable and null bytes replaced with . in ASCII column
    • Empty byte array
    • Mid-row gap after the 8th byte
    • Correct row count and offset values for multi-row input
  • fileBinaryPreviewQuery.test.tsx (7 tests) — covers useFileBinaryPreviewQuery:

    • Returns Uint8Array from a 206 Partial Content response
    • Returns Uint8Array from a 200 OK response (server ignores Range)
    • Sets error state on non-ok response
    • Does not fetch when enabled is false
    • Does not fetch when fspName is undefined
    • Sends correct Range: bytes=0-511 header
    • Includes credentials: 'include' in the request

Test plan

  • pixi run test-frontend — 18 test files, 124 tests, all passing

🤖 Generated with Claude Code

- hexDump.test.tsx: 11 tests covering offset/hex/ASCII formatting,
  mid-row gap, truncation message, non-printable byte substitution,
  empty input, and multi-row output
- fileBinaryPreviewQuery.test.tsx: 7 tests covering 206/200 responses,
  error state, disabled states (enabled=false, undefined fspName),
  Range header, and credentials

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@allison-truhlar allison-truhlar merged commit 5f6f5d1 into main Apr 10, 2026
3 checks passed
@allison-truhlar allison-truhlar deleted the mkitti-binary-file-display-tests branch April 10, 2026 13:39
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.

2 participants