Files
craft-libs/crates/ui/tests/it/components_index.rs
T

30 lines
1.2 KiB
Rust

//! The components index (`docs/components-index.md`) is what the registrations give, and the level tables name only
//! registered types.
use craft_ui::contract::stale_table_rows;
use craft_ui::testing::index::components_index;
use craft_ui::testing::library_registrations;
use craft_ui::testing::trial;
use std::path::Path;
#[trial]
fn the_committed_components_index_is_what_the_registrations_give() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let committed = std::fs::read_to_string(root.join("docs/components-index.md")).unwrap_or_default();
let registry = library_registrations();
let registrations: Vec<_> = registry.registrations().iter().collect();
assert!(
committed == components_index(&root, &registrations),
"docs/components-index.md is stale; run `cargo run -p craft-ui-gallery --bin components-index`"
);
}
/// Guards against a surface or story layout row whose type or story group is gone; the library's crates are linked
/// together only here.
#[trial]
fn the_level_tables_name_only_registered_types_and_story_groups() {
let registry = library_registrations();
let stale = stale_table_rows(&registry);
assert!(stale.is_empty(), "stale level table rows: {stale:#?}");
}