Skip to content

[test] Add unit tests for CommandHistory in @termuijs/core #1748

@pranvxag

Description

@pranvxag

What problem does this solve?

packages/core/src/history/CommandHistory.ts has no test file.
CommandHistory manages shell-style command history with navigation,
search, import/export, and size limits. None of this logic is currently
covered by tests, meaning regressions would go undetected.

Proposed solution

Create packages/core/src/history/CommandHistory.test.ts covering:

  • add() ignores empty/whitespace-only commands
  • add() stores valid commands in order
  • add() evicts oldest command when maxSize is exceeded
  • previous() navigates backward through history
  • previous() clamps at first command
  • previous() returns null when history is empty
  • next() navigates forward through history
  • next() returns null when past the last command
  • search() filters commands case-insensitively
  • getAll() returns a copy of all commands
  • clear() empties history and resets index
  • export() serializes history to JSON string
  • import() restores history from JSON string

Which package would this belong in?

@termuijs/core — packages/core/src/history/CommandHistory.test.ts

GSSoC contributor?

  • Yes. You contribute under GSSoC 2026 and want to work on this.
  • No. You are filing a suggestion.

Metadata

Metadata

Assignees

Labels

assignedIssue claimed by a contributor.type:feature+10 pts. New feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions