♻️ (pagetop): Deshabilita menús con with_disabled()
Cambia `link_disabled()`, `link_blank_disabled()` y `button_disabled()` de `nav::Item` y `dropdown::Item` por `with_disabled(bool)`, como en Button.
This commit is contained in:
parent
5d6852382a
commit
f1fd34f974
12 changed files with 123 additions and 93 deletions
|
|
@ -193,3 +193,42 @@ async fn separators_are_also_cleaned_in_a_dropdown_inside_a_nav() {
|
|||
assert!(!html.contains("dropdown-divider"), "{html}");
|
||||
assert!(html.contains("item-shown"), "{html}");
|
||||
}
|
||||
|
||||
// **< Disabled items >*****************************************************************************
|
||||
|
||||
async fn render_item(mut item: dropdown::Item) -> String {
|
||||
item.render(&mut Context::default()).await.into_string()
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn a_disabled_link_has_no_href() {
|
||||
let html = render_item(dropdown::Item::link(Lc::n("Home"), "/").with_disabled(true)).await;
|
||||
assert!(html.contains(r#"class="dropdown-item disabled""#), "{html}");
|
||||
assert!(html.contains(r#"aria-disabled="true""#));
|
||||
assert!(!html.contains("href="));
|
||||
|
||||
// Opening in a new window does not apply to a link that cannot be followed.
|
||||
let html = render_item(
|
||||
dropdown::Item::link_blank(Lc::n("Docs"), "https://docs.rs").with_disabled(true),
|
||||
)
|
||||
.await;
|
||||
assert!(!html.contains("target="), "{html}");
|
||||
|
||||
let html = render_item(dropdown::Item::link(Lc::n("Home"), "/").with_disabled(false)).await;
|
||||
assert!(html.contains(r#"href="/""#), "{html}");
|
||||
assert!(!html.contains("disabled"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn a_disabled_button_is_disabled() {
|
||||
let html = render_item(dropdown::Item::button(Lc::n("Save")).with_disabled(true)).await;
|
||||
assert!(html.contains(r#"aria-disabled="true""#), "{html}");
|
||||
assert!(html.contains(r#" disabled"#));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn disabled_does_not_apply_to_labels() {
|
||||
let label = render_item(dropdown::Item::label(Lc::n("Note"))).await;
|
||||
let disabled = render_item(dropdown::Item::label(Lc::n("Note")).with_disabled(true)).await;
|
||||
assert_eq!(label, disabled);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue