Skip to content

Commit a3bc14a

Browse files
committed
add snapshot test
1 parent 861518a commit a3bc14a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/testthat/_snaps/scale-.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020

2121
The `scale_name` argument of `binned_scale()` is deprecated as of ggplot2 3.5.0.
2222

23+
# mismatch between `na.value` and `palette` throws error
24+
25+
Code
26+
sc$map(x)
27+
Condition
28+
Error in `vec_assign()`:
29+
! Can't convert `na.value` <double> to match type of `palette` <character>.
30+
2331
# continuous scales warn about faulty `limits`
2432

2533
Code

tests/testthat/test-scale-.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ test_that("Using `scale_name` prompts deprecation message", {
138138

139139
})
140140

141+
test_that("mismatch between `na.value` and `palette` throws error", {
142+
x <- c("A", "B", "C", NA)
143+
sc <- scale_shape_manual(
144+
values = c("circle", "triangle", "square"),
145+
na.value = 4
146+
)
147+
sc$train(x)
148+
expect_snapshot(sc$map(x), error = TRUE)
149+
})
150+
141151
# Continuous scales -------------------------------------------------------
142152

143153
test_that("limits with NA are replaced with the min/max of the data for continuous scales", {

0 commit comments

Comments
 (0)