test_that("ss_control() work", {
# Vanilla
tag <- ss_control("demo", div())
expect_true(tag_has_attribute(tag, "data-controller"))
expect_equal(tag_get_attribute(tag, "data-controller"), "demo")
expect_string(as.character(tag), "demo")
# With Value
tag <- ss_control("demo", div(), values = list(hello = 1L))
expect_equal(tag_get_attribute(tag, "data-demo-hello-value"), "1")
# With Class
tag <- ss_control("demo", div(), classes = list(whoosh = "class"))
expect_equal(tag_get_attribute(tag, "data-demo-whoosh-class"), "class")
})
test_that("ss_target() work", {
tag <- ss_control("demo", div(ss_target("demo", input())))
expect_true(tag_has_attribute(tag$children[[1]], "data-demo-target"))
expect_equal(tag_get_attribute(tag$children[[1]], "data-demo-target"), "demo")
expect_string(as.character(tag), 'data-demo-target="demo"')
})
test_that("ss_action() work", {
tag <- ss_control("demo", div(ss_action("click", "action", button())))
expect_equal(tag_get_attribute(tag$children[[1]], "data-action"),
"click->demo#action")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.