11context(" labels" )
22
33test_that(" ggtitle is translated correctly" , {
4- ggiris <- ggplot(iris ) +
5- geom_point(aes(Petal.Width , Sepal.Width )) +
4+ ggpenguin <- ggplot(palmerpenguins :: penguins ) +
5+ geom_point(aes(bill_length_mm , bill_depth_mm )) +
66 ggtitle(" My amazing plot!" )
7- info <- expect_doppelganger_built(ggiris , " labels-ggtitle" )
7+ info <- expect_doppelganger_built(ggpenguin , " labels-ggtitle" )
88 expect_identical(info $ layout $ title $ text , " My amazing plot!" )
99})
1010
1111test_that(" ylab is translated correctly" , {
12- ggiris <- ggplot(iris ) +
13- geom_point(aes(Petal.Width , Sepal.Width )) +
14- ylab(" sepal width " )
15- info <- expect_doppelganger_built(ggiris , " labels-ylab" )
12+ ggpenguin <- ggplot(palmerpenguins :: penguins ) +
13+ geom_point(aes(bill_length_mm , bill_depth_mm )) +
14+ ylab(" bill depth " )
15+ info <- expect_doppelganger_built(ggpenguin , " labels-ylab" )
1616 labs <- c(info $ layout $ xaxis $ title $ text , info $ layout $ yaxis $ title $ text )
17- expect_identical(labs , c(" Petal.Width " , " sepal width " ))
17+ expect_identical(labs , c(" bill_length_mm " , " bill depth " ))
1818})
1919
2020test_that(" scale_x_continuous(name) is translated correctly" , {
21- ggiris <- ggplot(iris ) +
22- geom_point(aes(Petal.Width , Sepal.Width )) +
23- scale_x_continuous(" petal width " )
24- info <- expect_doppelganger_built(ggiris , " labels-scale_x_continuous_name" )
21+ ggpenguin <- ggplot(palmerpenguins :: penguins ) +
22+ geom_point(aes(bill_length_mm , bill_depth_mm )) +
23+ scale_x_continuous(" bill length " )
24+ info <- expect_doppelganger_built(ggpenguin , " labels-scale_x_continuous_name" )
2525 labs <- c(info $ layout $ xaxis $ title $ text , info $ layout $ yaxis $ title $ text )
26- expect_identical(labs , c(" petal width " , " Sepal.Width " ))
26+ expect_identical(labs , c(" bill length " , " bill_depth_mm " ))
2727})
2828
2929test_that(" angled ticks are translated correctly" , {
30- ggiris <- ggplot(iris ) +
31- geom_point(aes(Petal.Width , Sepal.Width )) +
30+ ggpenguin <- ggplot(palmerpenguins :: penguins ) +
31+ geom_point(aes(bill_length_mm , bill_depth_mm )) +
3232 theme(axis.text.x = element_text(angle = 45 ))
33- info <- expect_doppelganger_built(ggiris , " labels-angles" )
33+ info <- expect_doppelganger_built(ggpenguin , " labels-angles" )
3434 expect_identical(info $ layout $ xaxis $ tickangle , - 45 )
3535})
3636
3737test_that(" xaxis/yaxis automargin defaults to TRUE" , {
38- p <- ggplot(iris , aes(Species )) + geom_bar() + coord_flip()
38+ p <- ggplot(palmerpenguins :: penguins , aes(species )) + geom_bar() + coord_flip()
3939 l <- plotly_build(p )$ x
4040 expect_true(l $ layout $ xaxis $ automargin )
4141 expect_true(l $ layout $ yaxis $ automargin )
@@ -49,7 +49,8 @@ test_that("factor labels work", {
4949})
5050
5151test_that(" empty labels work" , {
52- p <- ggplot(iris , aes(Petal.Length , Sepal.Width , color = Species )) +
52+ p <- ggplot(palmerpenguins :: penguins ,
53+ aes(bill_length_mm , bill_depth_mm , color = species )) +
5354 geom_point() +
5455 labs(x = element_blank(), y = element_blank())
5556 b <- expect_doppelganger_built(p , " labs-element-blank" )
0 commit comments