tests/testthat/helper-functions.R

# Create a mock data extact spec for tests
mock_data_extract_spec <- function(dataname = "MOCK_DATASET",
                                   select_choices = sample(LETTERS, sample(2:10, 1)),
                                   select_multiple = FALSE) {
  teal.transform::data_extract_spec(
    dataname = dataname,
    select = teal.transform::select_spec(
      choices = select_choices,
      multiple = select_multiple
    )
  )
}

normalize_math_italic_text <- function(text) {
  # Unicode range for mathematical italic (uppercase/lowercase)
  math_italic <- intToUtf8(seq(0x1D434, 0x1D467)) # A-z

  # Standard letters
  latin <- c(LETTERS, letters)

  # Replace math italic letters with standard ones
  stringr::str_replace_all(
    text,
    setNames(latin, unlist(stringr::str_split(math_italic, "")))
  )
}

Try the teal.modules.general package in your browser

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

teal.modules.general documentation built on April 4, 2025, 2:26 a.m.