//! Names a consumer has to be able to say, proved from outside the crate. //! //! A unit test cannot check this: inside the crate every type is reachable //! through `crate::`, so a missing entry in `lib.rs`'s `pub use` list only //! shows up once something else does the `use`. `Curve` sat unexported that //! way until an audiofiles port tried to call `Field::curve`. use quasi_router::{Curve, Field, layout}; #[test] fn a_slider_can_be_given_a_curve_from_outside_the_crate() { let field = Field::range("gain", "Gain", "0", "1").curve(Curve::Logarithmic { step: Some("0.01".into()), }); field.with_layout(|drawn| { assert_eq!( drawn.curve, layout::Curve::Logarithmic { step: Some("0.01") } ); }); } /// The save shape and the pick a host answers with are both consumer-facing: /// audiofiles builds the first and hands back the second, so both have to be /// sayable from outside the crate. #[test] fn a_save_ask_and_its_answer_can_be_built_from_outside_the_crate() { use quasi_router::{Accepted, Action, Locating, Picked, Sought}; let asking = Locating::new( Sought::Save { name: "drums.afcl".into(), accept: vec![Accepted::suffix(".afcl")], }, "Export classifier", Action::post("/classifier/export"), "path", ); let call = asking .answered([Picked::new("/home/max/drums.afcl", "drums.afcl")]) .expect("a route to answer to"); assert_eq!(call.payload.get("path"), Some("/home/max/drums.afcl")); } /// A screen's document facts are the description's to state, so both the type /// and the gate a renderer asks about a name have to be sayable from outside /// the crate. #[test] fn a_document_can_be_built_and_its_names_checked_from_outside_the_crate() { use quasi_router::{Document, Screen, writable_root_attr}; let screen = Screen::list_detail("Admin", false).documented( Document::default() .classed("admin-page") .rooted("data-theme", "slate"), ); assert_eq!(screen.document.body_class.as_deref(), Some("admin-page")); assert!(writable_root_attr(&screen.document.root[0].0)); }