tests/testthat/test-favicon.R

test_that("test use_favicon", {
  with_dir(pkg, {
    use_favicon()
    expect_true(file.exists("inst/app/www/favicon.ico"))
    lapply(
      c(
        "test.jpeg",
        "test.bmp",
        "test.gif",
        "test.tiff"
      ),
      function(.x) {
        expect_error(
          use_favicon(path = .x)
        )
      }
    )
    golem::remove_favicon()
    expect_false(file.exists("inst/app/www/favicon.ico"))
  })
})

test_that("test use_favicon online", {
  with_dir(pkg, {
    skip_on_cran()
    golem::remove_favicon()
    expect_false(file.exists("inst/app/www/favicon.ico"))
    use_favicon(path = "https://fr.wikipedia.org//static/favicon/wikipedia.ico")
    expect_true(file.exists("inst/app/www/favicon.ico"))
  })
})
test_that("test use_favicon online fail", {
  with_dir(pkg, {
    golem::remove_favicon()
    expect_false(file.exists("inst/app/www/favicon.ico"))
    if (getRversion() >= "3.5") {
      expect_error(use_favicon(path = "https://fr.wikipedia.org//static/favicon/dontexist.ico"))
    }
    expect_false(file.exists("inst/app/www/favicon.ico"))
  })
})

test_that("test favicon", {
  with_dir(pkg, {
    expect_s3_class(
      favicon("jean", "jean"),
      "shiny.tag"
    )
  })
})

Try the golem package in your browser

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

golem documentation built on June 7, 2023, 5:46 p.m.