Skip to content

Commit b143ec6

Browse files
committed
included unit test for warnings if mapping or data is supplied
1 parent ab91c1e commit b143ec6

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/testthat/test-stats-function.r

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,10 @@ test_that("works with formula syntax", {
4848
expect_equal(ret$y, s^2)
4949
})
5050

51-
test_that("can control whether to preserve total or individual width", {
52-
df <- data_frame(x = c("a", "b", "b"), y = c("a", "a", "b"))
53-
54-
p_total <- ggplot(df, aes(x, fill = y)) +
55-
geom_bar(position = position_dodge(preserve = "total"), width = 1)
56-
p_single <- ggplot(df, aes(x, fill = y)) +
57-
geom_bar(position = position_dodge(preserve = "single"), width = 1)
51+
test_that("`mapping` is not used by stat_function()", {
52+
expect_warning(stat_function(aes(), fun = identity), "Ignoring `mapping`")
53+
})
5854

59-
expect_equal(layer_data(p_total)$x, c(1, 2.25, 1.75))
60-
expect_equal(layer_data(p_single)$x, c(0.75, 2.25, 1.75))
55+
test_that("`data` is not used by stat_function()", {
56+
expect_warning(stat_function(aes(), fun = identity), "Ignoring `data`")
6157
})

0 commit comments

Comments
 (0)