Skip to content

Commit

Permalink
use cheaper data.frame in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Oct 1, 2024
1 parent dcdc681 commit 9c7d168
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-aes-calculated.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test_that("make_labels() deparses mappings properly", {

test_that("staged aesthetics warn appropriately for duplicated names", {
# Test should *not* report `NA` as the duplicated aes (#4707)
df <- data.frame(x = 1, y = 1, lab = "test")
df <- data_frame0(x = 1, y = 1, lab = "test")

# One warning in plot code due to evaluation of `aes()`
expect_snapshot_warning(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-draw-key.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test_that("keys can communicate their size", {
# Orientation-aware key glyphs --------------------------------------------

test_that("horizontal key glyphs work", {
df <- data.frame(
df <- data_frame0(
middle = 1:2,
lower = 0:1,
upper = 2:3,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-facet-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ test_that("parsed labels are rendered correctly", {

test_that("outside-justified labels are justified across panels", {

df <- data.frame(
df <- data_frame0(
x = c("X\nX\nX\nX\nX", "X"),
y = c("YYYYY", "Y"),
f1 = c("A", "B"),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-geom-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ test_that("geom_sf data type renders appropriate legends", {

# Point data
data <- sf::st_as_sf(
data.frame(lon = c(1, 2), lat = c(3, 4), col = c("foo", "bar")),
data_frame0(lon = c(1, 2), lat = c(3, 4), col = c("foo", "bar")),
coords = c("lon", "lat")
)
expect_doppelganger(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-guides.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ test_that("guide merging for guide_legend() works as expected", {
})

test_that("size = NA doesn't throw rendering errors", {
df <- data.frame(
df <- data_frame0(
x = c(1, 2),
group = c("a", "b")
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-position_dodge.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("can control whether to preserve total or individual width", {

test_that("position_dodge() can dodge points vertically", {

df <- data.frame(x = c(1, 2, 3, 4), y = c("a", "a", "b", "b"))
df <- data_frame0(x = c(1, 2, 3, 4), y = c("a", "a", "b", "b"))

horizontal <- ggplot(df, aes(y, x, group = seq_along(x))) +
geom_point(position = position_dodge(width = 1, orientation = "x"))
Expand All @@ -26,7 +26,7 @@ test_that("position_dodge() can dodge points vertically", {

test_that("position_dodge() can reverse the dodge order", {

df <- data.frame(x = c(1, 2, 2, 3, 3), group = c("A", "A", "B", "B", "C"))
df <- data_frame0(x = c(1, 2, 2, 3, 3), group = c("A", "A", "B", "B", "C"))

# Use label as easy to track identifier
p <- ggplot(df, aes(x, y = 1, fill = group, label = group))
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-scale-discrete.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test_that("mapped_discrete vectors behaves as predicted", {

test_that("palettes work for discrete scales", {

df <- data.frame(x = c("A", "B", "C"), y = 1:3)
df <- data_frame0(x = c("A", "B", "C"), y = 1:3)
values <- c(1, 10, 100)

p <- ggplot(df, aes(x, y)) +
Expand All @@ -187,7 +187,7 @@ test_that("palettes work for discrete scales", {

test_that("invalid palettes trigger errors", {

df <- data.frame(x = c("A", "B", "C"), y = 1:3)
df <- data_frame0(x = c("A", "B", "C"), y = 1:3)

p <- ggplot(df, aes(x, y)) +
geom_point()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-sec-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ test_that("sec_axis() works for power transformations (monotonicity test doesn't

test_that("discrete scales can have secondary axes", {

data <- data.frame(x = c("A", "B", "C"), y = c("D", "E", "F"))
data <- data_frame0(x = c("A", "B", "C"), y = c("D", "E", "F"))
p <- ggplot(data, aes(x, y)) +
geom_point() +
scale_x_discrete(sec.axis = dup_axis(labels = c("foo", "bar", "baz"))) +
Expand Down

0 comments on commit 9c7d168

Please sign in to comment.