Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
graysonwhite committed Jan 16, 2024
1 parent fb40b59 commit facf0b6
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 1 deletion.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ Imports:
rlang,
vctrs
Suggests:
lme4
lme4,
testthat (>= 3.0.0)
URL: https://github.com/graysonwhite/gglm
BugReports: https://github.com/graysonwhite/gglm/issues
RoxygenNote: 7.2.3
Config/testthat/edition: 3
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(gglm)

test_check("gglm")
8 changes: 8 additions & 0 deletions tests/testthat/test-gglm.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod <- lm(mpg ~ wt, mtcars)
result <- gglm(mod)

test_that("is a patchwork'd ggplot", {
expect_s3_class(result, class = "patchwork", exact = FALSE)
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_cooks_leverage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_cooks_leverage()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_cooks_obs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_cooks_obs()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_fitted_resid.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_fitted_resid()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_normal_qq.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_normal_qq()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_resid_hist.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_resid_hist()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_resid_leverage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_resid_leverage()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-stat_scale_location.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(ggplot2)

mod <- lm(mpg ~ wt, mtcars)
result <- ggplot(data = mod) +
stat_scale_location()

test_that("is a ggplot", {
expect_s3_class(result, class = "gg", exact = FALSE)
expect_s3_class(result, class = "ggplot", exact = FALSE)
})

0 comments on commit facf0b6

Please sign in to comment.