File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -317,3 +317,38 @@ test_that("toWebGL() shouldn't complain if it's already webgl", {
317
317
toWebGL()
318
318
expect_silent(plotly_build(p ))
319
319
})
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
+ })
You can’t perform that action at this time.
0 commit comments