Skip to content

Organize tests by type and function - #99

Merged
ynqa merged 1 commit into
v0.14.0/devfrom
refactor/nest-unit-tests-by-function
Jul 28, 2026
Merged

Organize tests by type and function#99
ynqa merged 1 commit into
v0.14.0/devfrom
refactor/nest-unit-tests-by-function

Conversation

@ynqa

@ynqa ynqa commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

Reorganize tests so their module paths reflect the production type and function or method under test.

  • Standardize outer inline test modules as tests
  • Nest tests by production type and function or method
  • Rename generic test / test_* cases to describe the expected behavior
  • Split cases that covered multiple methods into focused tests
  • Align JSON/YAML integration test names with the behavior-oriented convention
  • Document the test organization rules in AGENTS.md

This makes test ownership clearer and produces more descriptive paths in cargo test output.

Scope

This is a test-organization refactor. No production API or runtime behavior changes are intended.

Verification

  • cargo fmt --all -- --check
  • cargo clippy
  • cargo test -- --nocapture --format pretty

Copilot AI review requested due to automatic review settings July 28, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the repository’s test organization so module paths reflect the production type and the function/method under test, improving cargo test output readability and test ownership clarity without intending to change runtime behavior.

Changes:

  • Re-names and re-nests unit tests into tests -> <type> -> <function/method> module hierarchies across crates.
  • Renames behavior-ambiguous test functions (e.g., test, test_*) to behavior-oriented names.
  • Documents the test-organization convention in AGENTS.md.

Reviewed changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
promkit/src/terminal_session.rs Reorganizes TerminalSession tests into nested modules by method/behavior.
promkit-widgets/tests/yamlz/multi_documents.rs Renames YAML integration test to behavior-oriented name.
promkit-widgets/tests/jsonz/up.rs Renames JSON navigation test to behavior-oriented name.
promkit-widgets/tests/jsonz/toggle.rs Renames JSON toggle tests to behavior-oriented names.
promkit-widgets/tests/jsonz/tail.rs Renames tail/JSONL tests to behavior-oriented names.
promkit-widgets/tests/jsonz/set_rows_visibility.rs Renames visibility test to behavior-oriented name.
promkit-widgets/tests/jsonz/render_pretty.rs Renames pretty-render test to behavior-oriented name.
promkit-widgets/tests/jsonz/multi_documents.rs Renames multi-document tests to behavior-oriented names.
promkit-widgets/tests/jsonz/head.rs Renames head/JSONL tests to behavior-oriented names.
promkit-widgets/tests/jsonz/get_all_paths.rs Renames path-extraction tests to behavior-oriented names.
promkit-widgets/tests/jsonz/extract.rs Renames extraction tests to behavior-oriented names.
promkit-widgets/tests/jsonz/down.rs Renames JSON navigation tests to behavior-oriented names.
promkit-widgets/tests/jsonz/create_rows.rs Renames row-creation tests to behavior-oriented names.
promkit-widgets/src/text/text.rs Restructures Text tests into per-method modules and splits navigation coverage.
promkit-widgets/src/text/config.rs Renames serde test module/test to behavior-oriented names.
promkit-widgets/src/text.rs Restructures State::hit_at tests into tests -> state -> hit_at.
promkit-widgets/src/text_editor/text_editor.rs Large re-org of TextEditor tests into nested per-method modules with clearer names.
promkit-widgets/src/text_editor/history.rs Splits history navigation tests into backward/forward modules with clearer names.
promkit-widgets/src/text_editor/config.rs Renames serde test module/test to behavior-oriented names.
promkit-widgets/src/text_editor.rs Restructures State::hit_at tests into nested modules by method.
promkit-widgets/src/table.rs Restructures Document and State tests into nested modules by type/method.
promkit-widgets/src/structured/yaml/document.rs Reorganizes YAML document parsing tests into from_str / from_reader modules.
promkit-widgets/src/structured/yaml/config.rs Wraps config tests under config and nests render_terminal_rows.
promkit-widgets/src/structured/yaml.rs Reorganizes YAML widget State tests into nested modules by method.
promkit-widgets/src/structured/tree/treez.rs Reorganizes tree adapter/row-op tests into nested modules by behavior.
promkit-widgets/src/structured/tree/config.rs Renames serde test module/test to behavior-oriented names.
promkit-widgets/src/structured/tree.rs Reorganizes tree widget State tests into nested modules by method.
promkit-widgets/src/structured/json/document.rs Reorganizes JSON document parsing tests into from_str / from_reader modules.
promkit-widgets/src/structured/json/config.rs Reorganizes config tests into config modules; renames serde tests for clarity.
promkit-widgets/src/structured/json.rs Reorganizes JSON widget State tests into nested modules by method.
promkit-widgets/src/prefix_search/prefix_search.rs Splits PrefixSearch tests by method (search, backward, forward, etc.).
promkit-widgets/src/prefix_search/config.rs Renames serde test module/test to behavior-oriented names.
promkit-widgets/src/prefix_search.rs Reorganizes State::create_graphemes tests into nested modules.
promkit-widgets/src/listbox/listbox.rs Splits Listbox tests by method with behavior-oriented names.
promkit-widgets/src/listbox/config.rs Renames serde test module/test to behavior-oriented names.
promkit-widgets/src/listbox.rs Reorganizes State::hit_at tests into nested modules.
promkit-widgets/src/checkbox/config.rs Renames serde test module/test to behavior-oriented names.
promkit-widgets/src/checkbox/checkbox.rs Reorganizes checkbox tests into per-method modules; renames generic test names.
promkit-widgets/src/checkbox.rs Reorganizes State::hit_at tests into nested modules.
promkit-core/src/widget.rs Reorganizes WidgetViewport tests into nested modules by method.
promkit-core/src/terminal.rs Reorganizes Terminal tests into nested modules by type/method.
promkit-core/src/render/layout.rs Reorganizes layout tests into nested modules by function/type.
promkit-core/src/render.rs Reorganizes renderer hit-test test into nested module.
promkit-core/src/grapheme.rs Renames/restructures StyledGraphemes tests into nested modules with clearer names.
examples/repl/src/repl.rs Reorganizes repl example tests into nested modules by function/behavior.
examples/csv/src/csv.rs Reorganizes csv example tests into nested modules by type/function.
AGENTS.md Documents the test-organization convention and example structure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 171 to +175
mod tests {
use super::*;

fn rows(count: usize) -> Vec<Vec<StyledGraphemes>> {
vec![
(0..count)
.map(|index| StyledGraphemes::from(format!("row {index}")))
.collect(),
]
}

fn command_bytes(command: impl crate::crossterm::Command) -> Vec<u8> {
let mut output = Vec::new();
crossterm::queue!(output, command).unwrap();
output
}

fn command_offset(output: &[u8], command: impl crate::crossterm::Command) -> usize {
let command = command_bytes(command);
output
.windows(command.len())
.position(|window| window == command)
.expect("expected terminal command was not emitted")
}
mod terminal {
use super::*;
@ynqa
ynqa merged commit 64b6078 into v0.14.0/dev Jul 28, 2026
2 checks passed
@ynqa
ynqa deleted the refactor/nest-unit-tests-by-function branch July 28, 2026 11:42
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