Skip to content

test(core): add UTF-8 Base64 regression cases #86

Description

@1amKhush

Problem

encodeBase64 is used to construct LNbits Basic Auth credentials and deliberately bridges UTF-8 bytes to the Web Platform btoa API. It currently has no focused regression tests for Unicode handling or Base64 padding.

Scope

Add src/core/utils/base64.test.ts covering:

  • empty input;
  • ordinary ASCII credentials;
  • one-byte and two-byte padding cases;
  • non-ASCII/UTF-8 credentials;
  • deterministic output matching known Base64 vectors.

Non-goals

  • Do not replace the implementation or introduce Node-only globals such as Buffer in production code.
  • Do not add LNbits integration or network tests.
  • Keep production changes out of scope unless a test exposes a confirmed defect.

Acceptance criteria

  • Expected values are independent known vectors rather than values generated by calling the function under test.
  • Tests exercise the browser-safe UTF-8 path.
  • Existing tests, lint, and type checking continue to pass.

Verification

bun test src/core/utils/base64.test.ts
bun lint
bun typecheck

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions