use super::repairability_index_scope::{RepairabilityIndexScope, repairability_index_scope};
#[test]
fn the_act_reaches_smartphones_and_slate_tablets_only() {
for t in ["smartphone", "tablet"] {
assert_eq!(
repairability_index_scope(t, None),
RepairabilityIndexScope::Covered,
"Art. 1 names {t}"
);
}
for t in ["other-mobile-phone", "cordless-phone"] {
assert_eq!(
repairability_index_scope(t, None),
RepairabilityIndexScope::NotCovered,
"{t} is outside 2023/1669"
);
}
}
#[test]
fn both_article_1_exclusions_are_expressible() {
assert_eq!(
repairability_index_scope("smartphone", Some("rollable-display")),
RepairabilityIndexScope::ExcludedRollableDisplay
);
assert_eq!(
repairability_index_scope("smartphone", Some("high-security-communication")),
RepairabilityIndexScope::ExcludedHighSecurity
);
assert_eq!(
repairability_index_scope("tablet", Some("rollable-display")),
RepairabilityIndexScope::ExcludedRollableDisplay
);
}
#[test]
fn an_undeclared_exclusion_is_not_an_exclusion() {
assert_eq!(
repairability_index_scope("smartphone", None),
RepairabilityIndexScope::Covered
);
for unknown in ["", " ", "flexible", "rollable_display", "secure"] {
assert_eq!(
repairability_index_scope("smartphone", Some(unknown)),
RepairabilityIndexScope::Covered,
"{unknown:?} must not exempt"
);
}
}
#[test]
fn the_device_type_is_decided_before_the_exclusion() {
assert_eq!(
repairability_index_scope("cordless-phone", Some("rollable-display")),
RepairabilityIndexScope::NotCovered
);
}
#[test]
fn matching_tolerates_case_and_surrounding_space() {
assert_eq!(
repairability_index_scope(" SmartPhone ", None),
RepairabilityIndexScope::Covered
);
assert_eq!(
repairability_index_scope("smartphone", Some(" High-Security-Communication ")),
RepairabilityIndexScope::ExcludedHighSecurity
);
}
#[test]
fn the_two_helpers_agree_with_the_variants() {
assert!(RepairabilityIndexScope::Covered.is_covered());
assert!(!RepairabilityIndexScope::Covered.is_declared_exclusion());
for excluded in [
RepairabilityIndexScope::ExcludedRollableDisplay,
RepairabilityIndexScope::ExcludedHighSecurity,
] {
assert!(!excluded.is_covered());
assert!(
excluded.is_declared_exclusion(),
"an operator said so, and a claim can be wrong"
);
}
assert!(!RepairabilityIndexScope::NotCovered.is_covered());
assert!(!RepairabilityIndexScope::NotCovered.is_declared_exclusion());
}