// Verifies that the breakpoint-based Bootstrap classes of `Container`, `Navbar`, `Dropdown` and // `Offcanvas` use the breakpoint names of `Bootsier::breakpoint_entry()`, and that `Xxxl` (absent // in Bootstrap) resolves as `xxl`. use pagetop::prelude::*; use pagetop_bootsier::theme::*; fn cx() -> Context { Context::default().with_theme(&pagetop_bootsier::Bootsier) } async fn container_html(width: impl Into>) -> String { let mut container = bs::Container::new() .with_width(width) .with_child(Html::with(|_| html! { p { "Content" } })); container.render(&mut cx()).await.into_string() } #[pagetop::test] async fn container_without_width_gets_the_bootstrap_default() { assert!(container_html(None).await.contains(r#"class="container""#)); assert!( container_html(bs::container::Width::Responsive) .await .contains(r#"class="container""#) ); } #[pagetop::test] async fn container_width_uses_breakpoint_name() { assert!( container_html(bs::container::Width::Fluid) .await .contains(r#"class="container-fluid""#) ); assert!( container_html(bs::container::Width::From(Breakpoint::Lg)) .await .contains(r#"class="container-lg""#) ); } #[pagetop::test] async fn container_width_xxxl_resolves_as_xxl() { assert!( container_html(bs::container::Width::From(Breakpoint::Xxxl)) .await .contains(r#"class="container-xxl""#) ); } #[pagetop::test] async fn dropdown_menu_align_combines_breakpoint_classes() { let cx = cx(); assert_eq!(bs::dropdown::MenuAlign::Start.to_class(&cx), ""); assert_eq!( bs::dropdown::MenuAlign::EndAt(Breakpoint::Md).to_class(&cx), "dropdown-menu-md-end" ); assert_eq!( bs::dropdown::MenuAlign::StartAndEnd(Breakpoint::Xl).to_class(&cx), "dropdown-menu-start dropdown-menu-xl-end" ); } async fn dropdown_menu_html(dropdown: bs::Dropdown) -> String { let mut dropdown = dropdown .with_title(Lc::n("Menu")) .with_item(bs::dropdown::Item::link(Lc::n("Home"), "/")); dropdown.render(&mut cx()).await.into_string() } #[pagetop::test] async fn dropdown_menu_end_maps_to_the_end_alignment() { let html = dropdown_menu_html(bs::Dropdown::new().with_menu_end(true)).await; assert!(html.contains(r#"