Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 841e7e9

Browse filesBrowse files
committed
Add test for translate_linebreaks()
1 parent 4cbf87d commit 841e7e9
Copy full SHA for 841e7e9

File tree

Expand file treeCollapse file tree

1 file changed

+35
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+35
-0
lines changed

‎tests/testthat/test-plotly.R

Copy file name to clipboardExpand all lines: tests/testthat/test-plotly.R
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,38 @@ test_that("toWebGL() shouldn't complain if it's already webgl", {
317317
toWebGL()
318318
expect_silent(plotly_build(p))
319319
})
320+
321+
test_that("Line breaks are properly translated (R -> HTML)", {
322+
skip_if_not_installed(pkg = "forcats")
323+
324+
# create target labels
325+
suffix <- "\n\n(third line)\n(fourth line)"
326+
327+
target_labels <- iris$Species %>%
328+
unique() %>%
329+
as.character() %>%
330+
paste0(suffix) %>%
331+
gsub(pattern = "\n",
332+
replacement = br(),
333+
x = .,
334+
fixed = TRUE)
335+
336+
# test factor column
337+
d <- iris %>% dplyr::mutate(Species = forcats::fct_relabel(Species,
338+
paste0,
339+
suffix))
340+
p1 <- d %>% plot_ly(x = ~Sepal.Length,
341+
y = ~Species)
342+
343+
expect_equivalent(plotly_build(p1)[["x"]][["layout"]][["yaxis"]][["categoryarray"]],
344+
target_labels)
345+
346+
# test character column
347+
p2 <- d %>%
348+
dplyr::mutate(Species = as.character(Species)) %>%
349+
plot_ly(x = ~Sepal.Length,
350+
y = ~Species)
351+
352+
expect_equivalent(plotly_build(p2)[["x"]][["layout"]][["yaxis"]][["categoryarray"]],
353+
target_labels)
354+
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.