use crate::graph::{GraphModel, OriginMount};
use super::tests::{app, compact, rendered};
fn watched() -> GraphModel {
GraphModel {
origins: vec![OriginMount {
mount: syn::parse_quote!(watch),
ty: syn::parse_quote!(app::Watch),
}],
..app()
}
}
#[test]
fn an_origin_gets_a_section_beside_the_nodes() {
let emitted = compact(&watched());
assert!(
emitted.contains(
"pub(crate)watch:::core::option::Option<::ingraph::__private::drive::NodeSection<::ingraph::__private::drive::Tuned<app::Watch>>>"
),
"{}",
rendered(&watched())
);
}
#[test]
fn an_origins_section_is_typed_by_its_own_faces_options() {
assert!(
!compact(&watched()).contains("<app::Watchas::ingraph::__private::drive::AsyncConstructor>"),
"{}",
rendered(&watched())
);
}
#[test]
fn an_origins_section_carries_no_channel_shelf() {
assert!(
!compact(&watched()).contains("<app::Watchas::ingraph::__private::drive::Declared>::Channels"),
"{}",
rendered(&watched())
);
}
#[test]
fn an_origin_takes_the_same_two_accessors_a_node_does() {
let emitted = compact(&watched());
assert!(
emitted.contains("pubfnwith_watch(mutself,"),
"{}",
rendered(&watched())
);
assert!(
emitted.contains("pubfnwatch(&self,)"),
"{}",
rendered(&watched())
);
}
#[test]
fn the_enablement_bridge_names_the_origins_beside_the_nodes() {
let emitted = compact(&watched());
for mount in ["videos", "scenes", "search", "watch"] {
assert!(
emitted.contains(&format!(
".mounted(\"{mount}\",::core::option::Option::as_ref(&self.{mount}))"
)),
"{mount}: {}",
rendered(&watched())
);
}
}
#[test]
fn the_debug_reports_an_origins_presence_too() {
assert!(
compact(&watched()).contains(".field(\"watch\",&::core::option::Option::is_some(&self.watch))"),
"{}",
rendered(&watched())
);
}
#[test]
fn a_root_that_mounts_no_origin_grows_no_section() {
assert!(!compact(&app()).contains("watch"), "{}", rendered(&app()));
}