Skip to content

Commit 1759873

Browse files
committed
fix bad error message for partial bundles and add a test
1 parent 7ecd204 commit 1759873

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

R/partial_bundles.R

+3-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ verify_partial_bundle <- function(p) {
109109
# (at this point, bundleType should never be 'auto' or 'main')
110110
missingTypes <- setdiff(types, bundleTraceMap[[bundleType]])
111111
if (length(missingTypes)) {
112-
msg <- sprint(
113-
"The '%s' bundle supports the following trace types: '%s'.\n\n",
114-
"This plotly visualization contains the following trace types: '%s'",
115-
bundle, paste(missingTypes, collapse = "', '"), paste(missingTypes, collapse = "', '")
112+
msg <- sprintf(
113+
"The '%s' bundle supports the following trace types: '%s'.\n\n This plotly visualization contains the following trace types: '%s'",
114+
bundleType, paste(bundleTraceMap[[bundleType]], collapse = "', '"), paste(missingTypes, collapse = "', '")
116115
)
117116
stop(msg, call. = FALSE)
118117
}

tests/testthat/test-plotly-partial-bundles.R

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ test_that("Can find the right bundle", {
3737
)
3838
})
3939

40+
test_that("Throws an informative error if wrong bundle is specified", {
41+
p1 <- plot_ly(z = ~volcano) %>% add_heatmap()
42+
43+
expect_error(
44+
partial_bundle(p1, type = "basic"),
45+
"The 'basic' bundle supports the following trace types: 'scatter', 'bar', 'pie'"
46+
)
47+
})
48+
4049
test_that("Can specify the partial bundle", {
4150
skip_on_cran()
4251

0 commit comments

Comments
 (0)