use stern4rust::rule_selection::RuleSelection;
const KNOWN: [&str; 3] = ["header", "test-file-structure", "tests-layout"];
fn selection(selected: &[&str], skipped: &[&str]) -> RuleSelection {
RuleSelection::new(
selected.iter().map(|name| (*name).to_string()).collect(),
skipped.iter().map(|name| (*name).to_string()).collect(),
)
}
#[test]
fn default_includes_every_rule() {
let selection = RuleSelection::default();
assert!(selection.includes("header"));
assert!(selection.includes("tests-layout"));
}
#[test]
fn includes_a_rule_that_was_selected() {
let selection = selection(&["header"], &[]);
assert!(selection.includes("header"));
}
#[test]
fn includes_of_a_rule_both_selected_and_skipped_is_false() {
let selection = selection(&["header"], &["header"]);
assert!(!selection.includes("header"));
}
#[test]
fn includes_of_a_rule_outside_an_explicit_selection_is_false() {
let selection = selection(&["header"], &[]);
assert!(!selection.includes("tests-layout"));
}
#[test]
fn includes_of_a_skipped_rule_is_false() {
let selection = selection(&[], &["tests-layout"]);
assert!(!selection.includes("tests-layout"));
assert!(selection.includes("header"));
}
#[test]
fn selects_explicitly_of_a_named_rule_is_true() {
let selection = selection(&["header"], &[]);
assert!(selection.selects_explicitly("header"));
}
#[test]
fn selects_explicitly_with_no_selection_is_false() {
let selection = RuleSelection::default();
assert!(!selection.selects_explicitly("header"));
}
#[test]
fn unknown_in_checks_both_switches() {
let selection = selection(&["heder"], &["tets-layout"]);
assert_eq!(selection.unknown_in(&KNOWN), ["heder", "tets-layout"]);
}
#[test]
fn unknown_in_names_a_misspelled_rule() {
let selection = selection(&[], &["test-file-strucutre"]);
assert_eq!(selection.unknown_in(&KNOWN), ["test-file-strucutre"]);
}
#[test]
fn unknown_in_of_valid_names_is_empty() {
let selection = selection(&["header"], &["tests-layout"]);
assert!(selection.unknown_in(&KNOWN).is_empty());
}