Skip to content

Commit 88f0654

Browse files
committed
adjust tests
1 parent 5824b1d commit 88f0654

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/testthat/test-geom-smooth.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ test_that("default smoothing methods for small and large data sets work", {
5757
y = x^2 + 0.5 * rnorm(1001)
5858
)
5959

60+
skip_if_not_installed("mgcv")
61+
6062
m <- mgcv::gam(y ~ s(x, bs = "cs"), data = df, method = "REML")
6163
range <- range(df$x, na.rm = TRUE)
6264
xseq <- seq(range[1], range[2], length.out = 80)
@@ -96,6 +98,18 @@ test_that("geom_smooth() works when one group fails", {
9698
expect_gte(nrow(ld), 2)
9799
})
98100

101+
test_that("a warning is thrown when `method = 'gam'` and {mgcv} is absent", {
102+
p <- ggplot(mpg, aes(displ, hwy)) +
103+
geom_smooth(method = "gam", formula = y ~ x)
104+
105+
with_mocked_bindings(
106+
expect_warning(
107+
ggplot_build(p), regexp = "package must be installed"
108+
),
109+
is_installed = function(...) FALSE
110+
)
111+
})
112+
99113
# Visual tests ------------------------------------------------------------
100114

101115
test_that("geom_smooth() works with alternative stats", {

0 commit comments

Comments
 (0)