Debian Codegraph @

tests/testthat/test-shiny.R

raw
1 test_that("file.path.ci returns correctly no matter the case", {
2 tmp_dir <- withr::local_tempdir()
3 expect_equal(file.path.ci(tmp_dir, "global.R"), file.path(tmp_dir, "global.R"))
4
5 withr::local_dir(tmp_dir)
6 expect_equal_file <- function(file, tmp_dir, default = file) {
7 withr::local_file(file); xfun::write_utf8("#dummy", file)
8 expect_equal(file.path.ci(!!tmp_dir, "global.R"), file.path(!!tmp_dir, !!default))
9 }
10 expect_equal_file("global.R", tmp_dir)
11 # on windows case in filename does not matter
12 # & MacOs in GHA is case insensitive
13 if (xfun::is_linux()) expect_equal_file("global.r", tmp_dir)
14 expect_equal_file("global.R", "donotexist")
15 expect_equal_file("global.Rmd", tmp_dir, "global.R")
16 })
17
18
19 test_that("set_current_theme() informs shiny::getCurrentTheme()", {
20 expect_null(shiny::getCurrentTheme())
21 theme <- bslib::bs_theme()
22 set_current_theme(theme)
23 expect_equal(theme, shiny::getCurrentTheme())
24 set_current_theme(NULL)
25 expect_null(shiny::getCurrentTheme())
26 })