Skip to content

Commit 304af85

Browse files
committed
Add unit tests for layer data extraction
1 parent 6bce655 commit 304af85

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/testthat/test-layer.r

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,16 @@ test_that("strip_dots remove dots around calculated aesthetics", {
3232
expect_equal(strip_dots(aes(sapply(..density.., function(x) mean(x)))$x),
3333
quote(sapply(density, function(x) mean(x))))
3434
})
35+
36+
# Data extraction ---------------------------------------------------------
37+
38+
test_that("layer_data returns a data.frame", {
39+
l <- geom_point()
40+
expect_equal(l$layer_data(mtcars), mtcars)
41+
l <- geom_point(data = head(mtcars))
42+
expect_equal(l$layer_data(mtcars), head(mtcars))
43+
l <- geom_point(data = head)
44+
expect_equal(l$layer_data(mtcars), head(mtcars))
45+
l <- geom_point(data = nrow)
46+
expect_error(l$layer_data(mtcars))
47+
})

0 commit comments

Comments
 (0)