Nothing
# ===========================================================================
# Tests for a11y_column
# ===========================================================================
# --- Width validation -------------------------------------------------------
test_that("a11y_column errors when width is less than 1", {
expect_error(
a11y_column(0, htmltools::p("Content")),
"width.*1 and 12"
)
})
test_that("a11y_column errors when width is greater than 12", {
expect_error(
a11y_column(13, htmltools::p("Content")),
"width.*1 and 12"
)
})
test_that("a11y_column errors when width is not numeric", {
expect_error(
a11y_column("six", htmltools::p("Content")),
"width"
)
})
test_that("a11y_column accepts valid widths (1-12)", {
for (w in 1:12) {
expect_no_error(a11y_column(w, htmltools::p("Content")))
}
})
# --- Offset validation ------------------------------------------------------
test_that("a11y_column errors when offset is less than 1", {
expect_error(
a11y_column(6, offset = 0, htmltools::p("Content")),
"offset.*1 and 12"
)
})
test_that("a11y_column errors when offset is greater than 12", {
expect_error(
a11y_column(6, offset = 13, htmltools::p("Content")),
"offset.*1 and 12"
)
})
test_that("a11y_column errors when offset is not numeric", {
expect_error(
a11y_column(6, offset = "two", htmltools::p("Content")),
"offset"
)
})
test_that("a11y_column accepts valid offsets", {
expect_no_error(a11y_column(6, offset = 3, htmltools::p("Content")))
})
# --- CSS class --------------------------------------------------------------
test_that("a11y_column has a11y-col and col-{width} classes", {
col <- a11y_column(6, htmltools::p("Content"))
html <- as.character(col)
expect_true(grepl("a11y-col", html))
expect_true(grepl("col-6", html))
})
# --- Data attributes --------------------------------------------------------
test_that("a11y_column sets data-width attribute", {
col <- a11y_column(8, htmltools::p("Content"))
expect_equal(col$attribs[["data-width"]], 8)
})
test_that("a11y_column sets data-offset attribute when offset is provided", {
col <- a11y_column(6, offset = 3, htmltools::p("Content"))
expect_equal(col$attribs[["data-offset"]], 3)
})
test_that("a11y_column does not set data-offset when offset is NULL", {
col <- a11y_column(6, htmltools::p("Content"))
expect_null(col$attribs[["data-offset"]])
})
# --- ID and aria_label passthrough ------------------------------------------
test_that("a11y_column passes id attribute", {
col <- a11y_column(6, htmltools::p("Content"), id = "my-col")
expect_equal(col$attribs$id, "my-col")
})
test_that("a11y_column passes aria_label attribute", {
col <- a11y_column(4, htmltools::p("Content"), aria_label = "Sidebar")
html <- as.character(col)
expect_true(grepl('aria-label=["\']Sidebar["\']', html))
})
# --- Tag type ---------------------------------------------------------------
test_that("a11y_column creates a div tag", {
col <- a11y_column(6, htmltools::p("Content"))
expect_equal(col$name, "div")
})
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.