Skip to content

Commit

Permalink
use testthat skip if no installed
Browse files Browse the repository at this point in the history
  • Loading branch information
donyunardi committed Aug 27, 2024
1 parent 8f2d5bc commit fe15bca
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions tests/testthat/test-plot_with_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ testthat::test_that("type_download_srv download all types of files and change th
})

testthat::test_that("type_download_srv downloads a png file with different dimensions", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

shiny::testServer(
teal.widgets:::type_download_srv,
Expand All @@ -252,9 +250,7 @@ testthat::test_that("type_download_srv downloads a png file with different dimen
})

testthat::test_that("type_download_srv downloads a png file using default dimensions input dimensions are NULL", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

shiny::testServer(
teal.widgets:::type_download_srv,
Expand Down Expand Up @@ -317,9 +313,8 @@ plot_with_settings_args <- list(
)

testthat::test_that("plot_with_settings_srv set dimensions and download a png file - base", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

plot_with_settings_args$plot_r <- function() plot(1)
shiny::testServer(
teal.widgets:::plot_with_settings_srv,
Expand All @@ -342,9 +337,7 @@ testthat::test_that("plot_with_settings_srv set dimensions and download a png fi
})

testthat::test_that("plot_with_settings_srv set dimensions and download a png file - ggplot2", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

plot_with_settings_args$plot_r <- function() {
ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) +
Expand All @@ -371,9 +364,7 @@ testthat::test_that("plot_with_settings_srv set dimensions and download a png fi
})

testthat::test_that("plot_with_settings_srv set dimensions and download a png file - grob", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

plot_with_settings_args$plot_r <- function() {
ggplot2::ggplotGrob(
Expand Down Expand Up @@ -402,9 +393,7 @@ testthat::test_that("plot_with_settings_srv set dimensions and download a png fi
})

testthat::test_that("plot_with_settings_srv set dimensions and download a png file - trellis", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

plot_with_settings_args$plot_r <- function() {
lattice::densityplot(1)
Expand All @@ -430,9 +419,7 @@ testthat::test_that("plot_with_settings_srv set dimensions and download a png fi
})

testthat::test_that("plot_with_settings_srv set dimensions and download a png file - WRONG type", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

plot_with_settings_args$plot_r <- function() 2

Expand Down Expand Up @@ -469,9 +456,7 @@ testthat::test_that("plot_with_settings_srv expand no error", {
})

testthat::test_that("plot_with_settings_srv set dimensions and download a png file from modal", {
if (!require("png", quietly = TRUE)) {
skip("png package not available")
}
testthat::skip_if_not_installed("png")

plot_with_settings_args[["plot_r"]] <- function() plot(1)
shiny::testServer(
Expand Down

0 comments on commit fe15bca

Please sign in to comment.