context("dsl") test_that("test icon type and input values", { # type expect_is(icon("deaf"), "shiny.tag") # empty input si_str <- as.character(icon("deaf")) expect_true(any(grepl("", si_str, fixed = TRUE))) # multiple input si_str <- as.character(icon("deaf", "a", "b", "c")) expect_true(any(grepl("\n a\n b\n c\n", si_str, fixed = TRUE))) }) test_that("test label type and input values", { # type expect_is(label(p("a")), "shiny.tag") # test input si_str <- as.character(label(p("a"))) expect_true(any(grepl("class=\"ui label \"", si_str, fixed = TRUE))) expect_match(as.character(label()), "") }) test_that("test tabset type and input values", { # test empty input expect_error(tabset()) si_str <- as.character(tabset(list( list(menu = div("First link"), content = div("First content")), list(menu = div("Second link"), content = div("Second content"), id = "second_tab")), active = "second_tab",) ) # check if tab id set correctly expect_true(any(grepl('data-tab=\"second_tab\"', si_str, fixed = TRUE))) # check if contains links expect_true(any(grepl("
First link
", si_str, fixed = TRUE))) # check if contains content expect_true(any(grepl("
Second content
", si_str, fixed = TRUE))) # check if tab set in active is actually the active tab expect_true(any(grepl('item active\" data-tab=\"second_tab', si_str, fixed = TRUE))) }) test_that("test header", { # test missing input expect_error(header()) expect_error(header("title")) si_str <- as.character(header(p("title"), "description")) expect_true(any(grepl(paste0("
", "description
"), si_str, fixed = TRUE))) # check icons si_str_with_icon <- as.character(header("title", "description", "car")) expect_true(any(grepl(paste0("
", "description
"), si_str, fixed = TRUE))) expect_true(any(grepl(paste0(""), si_str_with_icon, fixed = TRUE))) }) test_that("test cards", { # test missing input expect_match(as.character(cards()), "
") # test class expect_match(as.character(cards(class = "three")), "
") }) test_that("test card", { # test missing input expect_match(as.character(card()), "
") # test class expect_match(as.character(card(class = "one")), "
") }) test_that("test segment", { # test missing input expect_match(as.character(segment()), "
") # test class expect_match(as.character(segment(class = "one")), "
") }) test_that("test form", { # test missing input expect_match(as.character(form()), "
") # test class expect_match(as.character(form(class = "form")), "
") }) test_that("test fields", { # test missing input expect_match(as.character(fields()), "
") # test class expect_match(as.character(fields(class = "fl")), "
") }) test_that("test field", { # test missing input expect_match(as.character(field()), "
") # test class expect_match(as.character(field(class = "fl")), "
") }) test_that("test message_box", { # test missing input expect_error(message_box()) si_str <- as.character( message_box(shiny::h2("a"), c("b", "c")) ) # test output expect_true(any(grepl("
", si_str, fixed = TRUE))) expect_true(any(grepl("