11context(" partial-bundles" )
22
3-
4- test_that( " Can reduce saved file size with an auto partial bundle " , {
3+ test_that( " Can reduce saved file size with an basic (auto) partial bundle by half " , {
4+ skip_on_cran()
55
66 p1 <- plot_ly(x = 1 : 10 , y = 1 : 10 ) %> % add_markers()
77 p2 <- partial_bundle(p1 )
8+ expect_match(plotlyjsBundle(p2 )$ name , " basic" )
9+
810 f1 <- tempfile(fileext = " .html" )
911 f2 <- tempfile(fileext = " .html" )
10-
1112 file_size <- function (p , f ) {
1213 owd <- setwd(dirname(f ))
1314 on.exit(setwd(owd ))
@@ -16,3 +17,34 @@ test_that("Can reduce saved file size with an auto partial bundle", {
1617 }
1718 expect_true(file_size(p1 , f1 ) / 2 > file_size(p2 , f2 ))
1819})
20+
21+ test_that(" Can find the right bundle" , {
22+ skip_on_cran()
23+
24+ p1 <- plot_ly(z = ~ volcano ) %> % add_heatmap()
25+ p2 <- partial_bundle(p1 )
26+ expect_match(plotlyjsBundle(p2 )$ name , " cartesian" )
27+
28+ p3 <- plot_ly(z = ~ volcano ) %> % add_surface()
29+ p4 <- partial_bundle(p3 )
30+ expect_match(plotlyjsBundle(p3 )$ name , " gl3d" )
31+
32+ # At least right now, we don't support multiple partial bundles
33+ expect_warning(
34+ subplot(p1 , p3 ) %> % partial_bundle(),
35+ " Using the main (full) bundle" ,
36+ fixed = TRUE
37+ )
38+ })
39+
40+ test_that(" Can specify the partial bundle" , {
41+ skip_on_cran()
42+
43+ p1 <- plot_ly(x = 1 : 10 , y = 1 : 10 ) %> % add_markers()
44+ p2 <- partial_bundle(p1 , type = " basic" )
45+ p3 <- partial_bundle(p1 , type = " cartesian" )
46+
47+ expect_match(plotlyjsBundle(p2 )$ name , " basic" )
48+ expect_match(plotlyjsBundle(p3 )$ name , " cartesian" )
49+
50+ })
0 commit comments