Skip to content

Commit 622dcd0

Browse files
committed
tests
1 parent 8895f08 commit 622dcd0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/testthat/test-plotly.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ test_that("Discrete variable mapped to x creates horizontal bar chart", {
162162
expect_equal(unique(types), "histogram")
163163
})
164164

165-
165+
test_that("Can avoid inheriting attributes", {
166+
p <- plot_ly(mtcars, x = ~wt, y = ~mpg, color = I("red")) %>%
167+
add_histogram(x = ~factor(vs), inherit = FALSE)
168+
l <- expect_traces(p, 1, "inherit-FALSE")
169+
expect_equal(l$data[[1]][["type"]], "histogram")
170+
expect_equal(l$data[[1]][["x"]], factor(mtcars[["vs"]]))
171+
expect_null(l$data[[1]][["y"]])
172+
expect_true(l$data[[1]][["marker"]][["color"]] != toRGB("red"))
173+
})
166174

167175
test_that("Complex example works", {
168176
# note how median (the variable) doesn't exist in the second layer
@@ -181,7 +189,3 @@ test_that("Complex example works", {
181189

182190
l <- expect_traces(p, 3, "time-series-summary")
183191
})
184-
185-
186-
187-

0 commit comments

Comments
 (0)