test_that("background", { tdir <- tempdir() expect_no_error(exportStaticApp( result = omopgenerics::emptySummarisedResult(), directory = tdir, background = TRUE, open = FALSE )) unlink(file.path(tdir, "shiny"), recursive = TRUE) expect_no_error(exportStaticApp( result = omopgenerics::emptySummarisedResult(), directory = tdir, background = FALSE, open = FALSE )) unlink(file.path(tdir, "shiny"), recursive = TRUE) expect_snapshot(createBackground(TRUE) |> cat(sep = "\n")) expect_snapshot(createBackground(FALSE) |> cat(sep = "\n")) # existing md file backgroundFile <- tempfile(fileext = ".md") content <- "# test\n\ncustom background" writeLines(content, con = backgroundFile) expect_no_error(exportStaticApp( result = omopgenerics::emptySummarisedResult(), directory = tdir, background = backgroundFile, open = FALSE )) background <- readLines(file.path(tdir, "shiny", "background.md")) expect_identical(content, paste0(background, collapse = "\n")) unlink(file.path(tdir, "shiny"), recursive = TRUE) }) test_that("test backgroundCard", { tfile <- tempfile(fileext = ".md") def <- defaultBackground(logo = NULL) writeLines(def, con = tfile) expect_no_error(bkg <- backgroundCard(tfile)) expect_true(inherits(bkg, "bslib_fragment")) expect_snapshot(bkg |> as.character() |> cat()) unlink(tfile) })