tests/testthat/test-checkbox.R

test_that("Checkbox UI is generated and working correctly", {
  testthat::expect_equal(class(checkbox_ui), "function")
  testthat::expect_s3_class(checkbox_ui("test"), "shiny.tag")
})

# See ?testServer for more information
test_that("Checkbox Server is generated and working correctly", {
  shiny::testServer(checkbox_server, {
    # Set initial value of a button
    cat("Initially, check input is NULL, right?",
        is.null(input$check),
        "\n")
    session$setInputs(check = T)
    cat("Just set the value of the checkbox to T? ",
        input$check,
        "\n")
    expect_equal(input$check, T)
    expect_true(input$check)
    session$setInputs(check = F)
    expect_false(input$check)
  })
})
HarryRosen/hrimodules documentation built on Jan. 11, 2022, 12:36 a.m.