Skip to content

Commit 09aadb4

Browse files
committed
add some tests
1 parent d7c1150 commit 09aadb4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/testthat/test-plotly-getfigure.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ test_that("retrieving a public figure ... works.", {
2828
p <- plotly_build(fig)
2929
expect_equivalent(p$data[[1]]$x, c("1", "2", "3"))
3030
})
31+
32+
test_that("can add traces to a subplot figure", {
33+
skip_on_cran()
34+
fig <- get_figure('chelsea_lyn', 6366)
35+
p <- add_trace(fig, x=c(1, 2, 3), y=c(4, 2, 4))
36+
l <- plotly_build(p)
37+
expect_equivalent(length(fig$data) + 1, length(l$data))
38+
})
39+

tests/testthat/test-plotly.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,16 @@ test_that("axis titles get attached to scene object for 3D plots", {
9898
expect_identical(scene$yaxis$title, "Petal.Width")
9999
expect_identical(scene$zaxis$title, "Sepal.Width")
100100
})
101+
102+
test_that("inheriting properties works as expected", {
103+
library(dplyr)
104+
p <- iris %>%
105+
count(Species) %>%
106+
plot_ly(x = Species, y = n, opacity = 0.5, type = "bar", inherit = TRUE) %>%
107+
layout(barmode = "overlay", showlegend = FALSE)
108+
s <- count(iris[sample(nrow(iris), 10), ], Species)
109+
p2 <- add_trace(p, data = s)
110+
l <- plotly_build(p2)
111+
expect_equal(l$data[[2]]$opacity, 0.5)
112+
expect_true(all(l$data[[1]]$y > l$data[[2]]$y))
113+
})

0 commit comments

Comments
 (0)