Skip to content

Commit 08bcef5

Browse files
committed
move skipped expectations to end of test
1 parent 6a447ba commit 08bcef5

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

tests/testthat/_snaps/aes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# accessing an undefined variable results in an error
1+
# aes evaluated in environment where plot created
22

33
Code
44
get_layer_data(p)

tests/testthat/_snaps/empty-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Error in `combine_vars()`:
1515
! Faceting variables must have at least one value.
1616

17-
# Should error when totally empty data frame because there's no x and y
17+
# empty data overrides plot defaults
1818

1919
Code
2020
get_layer_data(d)

tests/testthat/test-aes.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,20 @@ test_that("aes evaluated in environment where plot created", {
4848
df <- data_frame(x = 1, y = 1)
4949
p <- ggplot(df, aes(foo, y)) + geom_point()
5050

51-
test_that("accessing an undefined variable results in an error", {
52-
skip_if(getRversion() <= "4.4.0")
53-
expect_snapshot(get_layer_data(p), error = TRUE)
54-
})
55-
5651
# Once it's defined we should get it back
5752
foo <- 0
5853
expect_equal(get_layer_data(p)$x, 0)
54+
rm(foo)
5955

6056
# And regular variable shadowing should work
6157
f <- function() {
6258
foo <- 10
6359
ggplot(df, aes(foo, y)) + geom_point()
6460
}
6561
expect_equal(get_layer_data(f())$x, 10)
62+
63+
skip_if(getRversion() <= "4.4.0")
64+
expect_snapshot(get_layer_data(p), error = TRUE)
6665
})
6766

6867
test_that("constants are not wrapped in quosures", {

tests/testthat/test-empty-data.R

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ test_that("layers with empty data are silently omitted with facet_grid", {
5353
})
5454

5555
test_that("empty data overrides plot defaults", {
56-
test_that("Should error when totally empty data frame because there's no x and y", {
57-
skip_if(getRversion() <= "4.4.0")
58-
d <- ggplot(mtcars, aes(mpg, wt)) +
59-
geom_point() +
60-
geom_point(data = data_frame())
61-
expect_snapshot(get_layer_data(d), error = TRUE)
62-
})
63-
6456
# No extra points when x and y vars don't exist but are set
6557
d <- ggplot(mtcars, aes(mpg, wt)) +
6658
geom_point() +
@@ -74,6 +66,12 @@ test_that("empty data overrides plot defaults", {
7466
geom_point(data = df0, x = 20, y = 3)
7567
expect_equal(nrow(get_layer_data(d, 1)), nrow(mtcars))
7668
expect_equal(nrow(get_layer_data(d, 2)), 0)
69+
70+
skip_if(getRversion() <= "4.4.0")
71+
d <- ggplot(mtcars, aes(mpg, wt)) +
72+
geom_point() +
73+
geom_point(data = data_frame())
74+
expect_snapshot(get_layer_data(d), error = TRUE)
7775
})
7876

7977
test_that("layer inherits data from plot when data = NULL", {

0 commit comments

Comments
 (0)