use crate::OrderDirection;
#[test]
fn the_flag_the_ordering_seam_takes_says_descending_for_desc_alone() {
assert!(OrderDirection::Desc.is_descending());
assert!(!OrderDirection::Asc.is_descending());
}
#[cfg(feature = "async-graphql")]
#[test]
fn the_direction_publishes_no_description_of_its_own_design() {
use async_graphql::{EmptyMutation, EmptySubscription, Object, Schema};
#[derive(Debug, Clone, Copy, PartialEq, Eq, async_graphql::OneofObject)]
enum Sorted {
Title(OrderDirection),
}
struct Query;
#[Object]
impl Query {
async fn rows(&self, sort: Sorted) -> bool {
matches!(sort, Sorted::Title(direction) if direction.is_descending())
}
}
let sdl = Schema::new(Query, EmptyMutation, EmptySubscription).sdl();
let at = sdl
.find("enum OrderDirection")
.unwrap_or_else(|| panic!("`OrderDirection` is in the schema: {sdl}"));
assert!(
!sdl[..at].trim_end().ends_with("\"\"\""),
"`OrderDirection` carries a description block: {sdl}"
);
for word in ["polarsync", "crate::Id", "unwrap_or_default"] {
assert!(!sdl.contains(word), "the SDL published `{word}`: {sdl}");
}
assert!(
sdl.contains("ASC") && sdl.contains("DESC"),
"the VALUES are still published — only their prose is not: {sdl}"
);
}