Nothing
# CSS classes
test_that("a11y_actionButton returns a shiny.tag with a11y-btn class", {
btn <- a11y_actionButton("btn1", label = "Click me")
expect_s3_class(btn, "shiny.tag")
html <- as.character(btn)
expect_true(grepl("a11y-btn", html))
})
test_that("a11y_actionButton passes extra class via ...", {
btn <- a11y_actionButton("btn10", label = "Go", class = "my-extra")
html <- as.character(btn)
expect_true(grepl("a11y-btn", html))
expect_true(grepl("my-extra", html))
})
# Label and/or ARIA label missing
test_that("errors when label and aria_label are both missing", {
expect_error(
a11y_actionButton("btn3"),
"aria_label"
)
})
test_that("errors when label is empty and aria_label is missing", {
expect_error(
a11y_actionButton("btn4", label = ""),
"aria_label"
)
})
test_that("errors when label and aria_label are both empty", {
expect_error(
a11y_actionButton("btn5", label = "", aria_label = ""),
"aria_label"
)
})
test_that("does not set aria-label when visible label is provided", {
btn <- a11y_actionButton("btn8", label = "Save")
html <- as.character(btn)
expect_false(grepl("aria-label", html))
})
test_that("a11y_actionButton accepts aria_label when label is missing", {
btn <- a11y_actionButton("btn6", aria_label = "Close dialog")
html <- as.character(btn)
expect_true(grepl('aria-label=["\']Close dialog["\']', html))
})
# ARIA controls
test_that("a11y_actionButton sets aria-controls when provided", {
btn <- a11y_actionButton("btn7", label = "Toggle", aria_controls = "panel1")
html <- as.character(btn)
expect_true(grepl('aria-controls=["\']panel1["\']', html))
})
# Icons
test_that("marks icon as aria-hidden", {
btn <- a11y_actionButton(
"btn9",
label = "Delete", icon = shiny::icon("trash")
)
html <- as.character(btn)
expect_true(grepl('aria-hidden=["\']true["\']', html))
})
# Id handling in error message
test_that("a11y_actionButton error message includes inputId", {
expect_error(
a11y_actionButton("mySpecialId", label = ""),
"mySpecialId"
)
})
# Dependency attachment
test_that("a11y_actionButton attaches a11yShiny dependency", {
btn <- a11y_actionButton("btn_dep", label = "Click")
deps <- htmltools::htmlDependencies(btn)
dep_names <- vapply(deps, function(d) d$name, character(1))
expect_true("a11yShiny" %in% dep_names)
})
# Icon-only button with aria_label
test_that("a11y_actionButton icon-only button with aria_label works", {
btn <- a11y_actionButton(
"btn_icon_only",
icon = shiny::icon("search"),
aria_label = "Search"
)
html <- as.character(btn)
expect_true(grepl('aria-label=["\']Search["\']', html))
expect_true(grepl('aria-hidden=["\']true["\']', html))
})
# aria_controls with aria_label (no visible label)
test_that("a11y_actionButton combines aria_label and aria_controls", {
btn <- a11y_actionButton(
"btn_ctrl_aria",
aria_label = "Toggle sidebar",
aria_controls = "sidebar"
)
html <- as.character(btn)
expect_true(grepl('aria-label=["\']Toggle sidebar["\']', html))
expect_true(grepl('aria-controls=["\']sidebar["\']', html))
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.