Skip to content

Commit

Permalink
remove unnecessary keyword args in testthat calls
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Dec 4, 2023
1 parent 206c32d commit d40b42a
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 100 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/test-combine_plots.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that(
desc = "checking if combining plots works",
code = {
"checking if combining plots works",
{
p1 <- ggplot2::ggplot(
data = subset(iris, iris$Species == "setosa"),
aes(x = Sepal.Length, y = Sepal.Width)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-extract_stats.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that(
desc = "checking if extract_stats works",
code = {
"checking if extract_stats works",
{
skip_if_not_installed("PMCMRplus")
skip_if_not_installed("rstantools")
options(tibble.width = Inf)
Expand Down
28 changes: 14 additions & 14 deletions tests/testthat/test-ggbarstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ survey_data_NA <- dplyr::tibble(
# checking default outputs -----------------------------------------

test_that(
desc = "checking default outputs",
code = {
"checking default outputs",
{
set.seed(123)
expect_doppelganger(
title = "checking unpaired two-way table - without NA",
Expand Down Expand Up @@ -59,8 +59,8 @@ test_that(
# changing labels and aesthetics -------------------------------------------

test_that(
desc = "changing labels and aesthetics",
code = {
"changing labels and aesthetics",
{
set.seed(123)
expect_doppelganger(
title = "checking percentage labels",
Expand Down Expand Up @@ -156,8 +156,8 @@ test_that(
# edge cases ---------------------------------------------------------

test_that(
desc = "edge cases",
code = {
"edge cases",
{
# dropped level dataset
mtcars_small <- dplyr::filter(mtcars, am == "0")

Expand All @@ -179,8 +179,8 @@ test_that(
# expression output --------------------------------------------------

test_that(
desc = "expression output",
code = {
"expression output",
{
set.seed(123)
p_sub <- ggbarstats(
data = ggplot2::msleep,
Expand All @@ -203,15 +203,15 @@ test_that(
)

test_that(
desc = "grouped_ggbarstats produces error when grouping variable not provided",
code = {
"grouped_ggbarstats produces error when grouping variable not provided",
{

Check warning on line 207 in tests/testthat/test-ggbarstats.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-ggbarstats.R,line=207,col=3,[unnecessary_nesting_linter] Reduce the nesting of this statement by removing the braces {}.

Check warning on line 207 in tests/testthat/test-ggbarstats.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-ggbarstats.R,line=207,col=3,[unnecessary_nesting_linter] Reduce the nesting of this statement by removing the braces {}.
expect_snapshot(grouped_ggbarstats(mtcars, x = cyl, y = am), error = TRUE)
}
)

test_that(
desc = "grouped_ggbarstats works",
code = {
"grouped_ggbarstats works",
{
# creating a smaller data frame
mpg_short <- ggplot2::mpg %>%
dplyr::filter(
Expand All @@ -238,8 +238,8 @@ test_that(
# edge cases --------------------

test_that(
desc = "edge case behavior",
code = {
"edge case behavior",
{
df <- data.frame(
dataset = c("a", "b", "c", "c", "c", "c"),
measurement = c("old", "old", "old", "old", "new", "new"),
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-ggbetweenstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ skip_if_not_installed("rstantools")
# checking labels and data from plot -------------------------------------

test_that(
desc = "plotting features work as expected",
code = {
"plotting features work as expected",
{
set.seed(123)
expect_doppelganger(
title = "modification with ggplot2 works as expected",
Expand Down Expand Up @@ -59,8 +59,8 @@ test_that(
# subtitle output works ------------------------------------------------

test_that(
desc = "subtitle output works",
code = {
"subtitle output works",
{
skip_on_cran()

df <- mtcars
Expand Down Expand Up @@ -89,8 +89,8 @@ test_that(
# grouped_ggbetweenstats defaults --------------------------------------------------

test_that(
desc = "grouped_ggbetweenstats defaults",
code = {
"grouped_ggbetweenstats defaults",
{
# expect error when no grouping.var is specified
expect_snapshot_error(grouped_ggbetweenstats(mtcars, x = am, y = wt))

Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-ggcoefstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ test_that("meta-analysis works", {
# plot modifications--------------------------------------------------

test_that(
desc = "plot modifications work as expected",
code = {
"plot modifications work as expected",
{
set.seed(123)
mod1 <- stats::lm(data = mtcars, formula = wt ~ mpg * am)

Expand Down Expand Up @@ -131,8 +131,8 @@ test_that(
# edge cases -------------------------------------

test_that(
desc = "works when CIs unavailable",
code = {
"works when CIs unavailable",
{
set.seed(123)
df_base <- tidy_model_parameters(stats::lm(wt ~ am * cyl, mtcars))

Expand All @@ -154,8 +154,8 @@ test_that(
# meta subtitle and caption -------------------------------------

test_that(
desc = "meta analysis subtitle and caption",
code = {
"meta analysis subtitle and caption",
{
skip_on_cran()
skip_if_not_installed("metafor")
skip_if_not_installed("metaBMA")
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-ggcorrmat.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that(
desc = "checking ggcorrmat with entier dataset",
code = {
"checking ggcorrmat with entier dataset",
{
set.seed(123)
expect_doppelganger(
title = "parametric correlation - without NAs",
Expand All @@ -18,8 +18,8 @@ test_that(
# changing defaults -------------------------------------------

test_that(
desc = "ggcorrmat works as expected with changed defaults",
code = {
"ggcorrmat works as expected with changed defaults",
{
set.seed(123)
expect_doppelganger(
title = "changing aesthetic defaults",
Expand Down Expand Up @@ -61,8 +61,8 @@ test_that(
# grouped_ggcorrmat output: plot ---------------------------------------------------------------

test_that(
desc = "grouped_ggcorrmat plots are as expected",
code = {
"grouped_ggcorrmat plots are as expected",
{
set.seed(123)
expect_doppelganger(
title = "without NAs",
Expand All @@ -87,8 +87,8 @@ test_that(
# expected warnings -------------------------------------------

test_that(
desc = "grouped_ggcorrmat produces error when grouping isn't specified",
code = {
"grouped_ggcorrmat produces error when grouping isn't specified",
{
expect_snapshot(grouped_ggcorrmat(iris), error = TRUE)
}
)
16 changes: 8 additions & 8 deletions tests/testthat/test-ggdotplotstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ morley_new[87L, 3L] <- NA_integer_
# checking default outputs -----------------------------------------

test_that(
desc = "checking default outputs",
code = {
"checking default outputs",
{
set.seed(123)
expect_doppelganger(
title = "parametric - without NA",
Expand All @@ -38,8 +38,8 @@ test_that(
# modification with ggplot2 ----------------------------------------------

test_that(
desc = "modification with ggplot2 works as expected",
code = {
"modification with ggplot2 works as expected",
{
set.seed(123)
expect_doppelganger(
title = "modification with ggplot2 ",
Expand All @@ -63,8 +63,8 @@ test_that(
# subtitle output -------------------------------------------------------

test_that(
desc = "subtitle output",
code = {
"subtitle output",
{
set.seed(123)
p_sub_ggdot <- suppressWarnings(ggdotplotstats(
data = morley,
Expand Down Expand Up @@ -93,8 +93,8 @@ test_that(
# grouped_ggdotplotstats works -----------------------------------------------

test_that(
desc = "grouped_ggdotplotstats works",
code = {
"grouped_ggdotplotstats works",
{
# removing factor level with very few no. of observations
df <- dplyr::filter(ggplot2::mpg, cyl %in% c("4", "6", "8"))

Expand Down
24 changes: 12 additions & 12 deletions tests/testthat/test-gghistostats.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# checking default outputs -----------------------------------------

test_that(
desc = "checking default outputs",
code = {
"checking default outputs",
{
set.seed(123)
expect_doppelganger(
title = "parametric - without NA",
Expand All @@ -20,8 +20,8 @@ test_that(
# aesthetic modifications work --------------------------------------

test_that(
desc = "aesthetic modifications work",
code = {
"aesthetic modifications work",
{
set.seed(123)
expect_doppelganger(
title = "aesthetic modifications work",
Expand All @@ -45,8 +45,8 @@ test_that(
# normal curve works -------------------------------------

test_that(
desc = "checking if normal curve work",
code = {
"checking if normal curve work",
{
set.seed(123)
expect_doppelganger(
title = "plot normal curve",
Expand All @@ -65,8 +65,8 @@ test_that(
# subtitle output --------------------------------------------------

test_that(
desc = "subtitle output",
code = {
"subtitle output",
{
set.seed(123)
p_sub <- gghistostats(
data = ggplot2::msleep,
Expand All @@ -91,17 +91,17 @@ test_that(
# utilities ---------------

test_that(
desc = ".binwidth works as expected",
code = {
".binwidth works as expected",
{
expect_equal(ggstatsplot:::.binwidth(mtcars$wt), 0.6913737, tolerance = 0.001)
}
)

# grouped_gghistostats works ---------------------------------------------

test_that(
desc = "grouped_gghistostats plotting works as expected",
code = {
"grouped_gghistostats plotting works as expected",
{
set.seed(123)
expect_doppelganger(
title = "defaults as expected",
Expand Down
28 changes: 14 additions & 14 deletions tests/testthat/test-ggpiestats.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ survey_data_NA <- dplyr::tibble(
# checking default outputs -----------------------------------------

test_that(
desc = "checking default outputs",
code = {
"checking default outputs",
{
set.seed(123)
expect_doppelganger(
title = "checking one-way table - without NA",
Expand Down Expand Up @@ -70,8 +70,8 @@ test_that(
# changing labels and aesthetics -------------------------------------------

test_that(
desc = "changing labels and aesthetics",
code = {
"changing labels and aesthetics",
{
set.seed(123)
expect_doppelganger(
title = "checking percentage labels",
Expand Down Expand Up @@ -142,8 +142,8 @@ test_that(
# edge cases ---------------------------------------------------------

test_that(
desc = "edge cases",
code = {
"edge cases",
{
# dropped level dataset
mtcars_small <- dplyr::filter(mtcars, am == "0")

Expand All @@ -165,8 +165,8 @@ test_that(
# expression output --------------------------------------------------

test_that(
desc = "expression output",
code = {
"expression output",
{
set.seed(123)
p_sub <- ggpiestats(
ggplot2::msleep,
Expand All @@ -191,15 +191,15 @@ test_that(
# grouped_ggpiestats works as expected ---------------------

test_that(
desc = "grouped_ggpiestats produces error when grouping variable not provided",
code = {
"grouped_ggpiestats produces error when grouping variable not provided",
{
expect_snapshot_error(grouped_ggpiestats(mtcars, x = cyl))
}
)

test_that(
desc = "grouped_ggpiestats works",
code = {
"grouped_ggpiestats works",
{
set.seed(123)
expect_doppelganger(
title = "grouped_ggpiestats with one-way table",
Expand Down Expand Up @@ -236,8 +236,8 @@ test_that(
# grouped_ggpiestats edge cases --------------------

test_that(
desc = "edge case behavior",
code = {
"edge case behavior",
{
df <- data.frame(
dataset = c("a", "b", "c", "c", "c", "c"),
measurement = c("old", "old", "old", "old", "new", "new"),
Expand Down
Loading

0 comments on commit d40b42a

Please sign in to comment.