1
1
context(" partial-bundles" )
2
2
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()
5
5
6
6
p1 <- plot_ly(x = 1 : 10 , y = 1 : 10 ) %> % add_markers()
7
7
p2 <- partial_bundle(p1 )
8
+ expect_match(plotlyjsBundle(p2 )$ name , " basic" )
9
+
8
10
f1 <- tempfile(fileext = " .html" )
9
11
f2 <- tempfile(fileext = " .html" )
10
-
11
12
file_size <- function (p , f ) {
12
13
owd <- setwd(dirname(f ))
13
14
on.exit(setwd(owd ))
@@ -16,3 +17,34 @@ test_that("Can reduce saved file size with an auto partial bundle", {
16
17
}
17
18
expect_true(file_size(p1 , f1 ) / 2 > file_size(p2 , f2 ))
18
19
})
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