Skip to content

Commit 401ade1

Browse files
committed
add tests
1 parent 32a5a3e commit 401ade1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/testthat/test-plotly-color.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ test_that("Mapping a numeric variable to color works", {
6363
expect_true(all(0 <= markerScale$colorscale[,1] & markerScale$colorscale[,1] <= 1))
6464
})
6565

66+
test_that("color/stroke mapping with box translates correctly", {
67+
d <- data.frame(x = rep(c("A", "B"), each = 5), y = rnorm(10))
68+
l <- plot_ly(d) %>%
69+
add_boxplot(x = ~x, y = ~y, color = ~x, colors = c('A' = "blue", 'B' = "red"), stroke = I("black")) %>%
70+
expect_traces(2, "box-color-stroke")
71+
expect_true(l$data[[1]]$fillcolor == toRGB("blue", 0.5))
72+
expect_true(l$data[[2]]$fillcolor == toRGB("red", 0.5))
73+
expect_true(l$data[[1]]$line$color == toRGB("black"))
74+
expect_true(l$data[[2]]$line$color == toRGB("black"))
75+
})
76+
6677
test_that("Custom RColorBrewer pallette works for numeric variable", {
6778
p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length,
6879
color = ~Petal.Width, colors = "Greens")

tests/testthat/test-plotly-size.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,18 @@ test_that("sizemode is always respected", {
1818
}
1919

2020
})
21+
22+
23+
test_that("Basic bubble chart works without warning", {
24+
p <- plot_ly(
25+
data = iris,
26+
x = ~Sepal.Length,
27+
y = ~Petal.Length,
28+
size = ~Sepal.Width,
29+
type = 'scatter',
30+
mode = 'markers'
31+
)
32+
# expect no warning
33+
expect_warning(plotly_build(p), NA)
34+
expect_doppelganger_built(p, "bubble-chart")
35+
})

0 commit comments

Comments
 (0)