Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jan 12, 2022
1 parent 9709497 commit 303a83d
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 0 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Suggests:
testthat (>= 3.1.1),
tibble,
units (>= 0.7.2),
vdiffr,
withr
VignetteBuilder:
knitr
Expand Down
63 changes: 63 additions & 0 deletions tests/testthat/_snaps/ggplot2/basic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions tests/testthat/_snaps/ggplot2/log-scale.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions tests/testthat/_snaps/unicode/ctl_colonnade.new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# color

Code
style_na("NA")
Output
[1] "\033[31mNA\033[39m"
Code
style_neg("-1")
Output
[1] "\033[31m-1\033[39m"

---

Code
ctl_colonnade(list(a_very_long_column_name = 0), width = 20)
Output
$body
$extra_cols
$extra_cols$a_very_long_column_name
[1] 0

24 changes: 24 additions & 0 deletions tests/testthat/test-ggplot2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
test_that("ggplot2 snapshot tests", {
skip_if_not_installed("ggplot2")
skip_if_not_installed("vdiffr")
skip_if_not_installed("tibble")

data <- tibble::tibble(
x = num((1:10) / 100, fixed_exponent = -3, notation = "eng"),
y = num((1:10) / 100, scale = 100, label = "%"),
z = num(10^(-5:4), notation = "si")
)

basic <-
ggplot2::ggplot(data, ggplot2::aes(x, y)) +
ggplot2::geom_point()

vdiffr::expect_doppelganger("basic", basic)

log_scale <-
ggplot2::ggplot(data, ggplot2::aes(x, z)) +
ggplot2::geom_point() +
scale_y_num(trans = "log10")

vdiffr::expect_doppelganger("log_scale", log_scale)
})

0 comments on commit 303a83d

Please sign in to comment.