tests/testthat/test-dropdownTabDirect.R

test_that("dropdownTabDirect creates the correct dropdown menu with tab selection", {
  # Run the function
  test_obj <- dropdownTabDirect(type = "messages", tab_name = "Tab1", title = "Interesting tab")

  # Check the class of the output
  expect_s3_class(test_obj, "shiny.tag")

  # Check the name of the tag
  expect_equal(test_obj$name, "li")

  # Check that the dropdown type is "messages"
  dropdown_class <- paste0("dropdown ", "messages", "-menu")
  expect_equal(test_obj$attribs$class, dropdown_class)

  # Check the 'data-tab-name' attribute
  expect_equal(test_obj$children[[1]]$attribs$`data-tab-name`, "Tab1")

  # Check the 'onclick' attribute
  expect_equal(test_obj$children[[1]]$attribs$onclick, "shinyjs.tabSelect('Tab1')")
})

Try the vvshiny package in your browser

Any scripts or data that you put into this service are public.

vvshiny documentation built on July 26, 2023, 5:50 p.m.