✨ (base): Añade with_menu_end() para menú al final
This commit is contained in:
parent
f265f217bd
commit
165cb49880
7 changed files with 152 additions and 5 deletions
50
tests/component_dropdown.rs
Normal file
50
tests/component_dropdown.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
fn dropdown() -> Dropdown {
|
||||
Dropdown::new()
|
||||
.with_title(Lc::n("Menu"))
|
||||
.with_item(dropdown::Item::link(Lc::n("Home"), "/"))
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn menu_is_aligned_to_the_start_by_default() {
|
||||
let html = dropdown()
|
||||
.render(&mut Context::default())
|
||||
.await
|
||||
.into_string();
|
||||
|
||||
assert!(html.contains(r#"<ul class="dropdown-menu">"#));
|
||||
assert!(!html.contains("dropdown-menu-end"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn menu_end_adds_the_end_class() {
|
||||
let html = dropdown()
|
||||
.with_menu_end(true)
|
||||
.render(&mut Context::default())
|
||||
.await
|
||||
.into_string();
|
||||
|
||||
assert!(html.contains(r#"<ul class="dropdown-menu dropdown-menu-end">"#));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn menu_end_applies_to_a_dropdown_inside_a_nav() {
|
||||
let mut nav = Nav::new().with_item(nav::Item::dropdown(dropdown().with_menu_end(true)));
|
||||
let html = nav.render(&mut Context::default()).await.into_string();
|
||||
|
||||
assert!(html.contains(r#"<ul class="dropdown-menu dropdown-menu-end">"#));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn menu_end_is_ignored_without_title() {
|
||||
let html = Dropdown::new()
|
||||
.with_menu_end(true)
|
||||
.with_item(dropdown::Item::link(Lc::n("Home"), "/"))
|
||||
.render(&mut Context::default())
|
||||
.await
|
||||
.into_string();
|
||||
|
||||
assert!(html.contains(r#"<ul class="dropdown-menu">"#));
|
||||
assert!(!html.contains("dropdown-menu-end"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue