Skip to content

Commit

Permalink
Add unit tests for mapped_discrete vector class (#4010)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 authored May 19, 2020
1 parent f802c5e commit dbbcd43
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/testthat/test-scale-discrete.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ test_that("discrete non-position scales can accept functional limits", {
expect_identical(scale$get_limits(), c("c", "b", "a"))
})


test_that("discrete scale defaults can be set globally", {
df <- data_frame(
x = 1:4, y = 1:4,
Expand Down Expand Up @@ -127,5 +126,19 @@ test_that("discrete scale defaults can be set globally", {
expect_equal(layer_data(four)$colour, c("#FF0000", "#00FF00", "#0000FF", "#FF00FF"))
expect_equal(layer_data(four)$fill, c("#FF0000", "#00FF00", "#0000FF", "#FF00FF"))
})
})

# mapped_discrete ---------------------------------------------------------

test_that("mapped_discrete vectors behaves as predicted", {
expect_null(new_mapped_discrete(NULL))
expect_s3_class(new_mapped_discrete(c(0, 3.5)), "mapped_discrete")
expect_s3_class(new_mapped_discrete(seq_len(4)), "mapped_discrete")
expect_error(new_mapped_discrete(letters))

x <- new_mapped_discrete(1:10)
expect_s3_class(x[2:4], "mapped_discrete")
expect_s3_class(c(x, x), "mapped_discrete")
x[5:7] <- new_mapped_discrete(seq_len(3))
expect_s3_class(x, "mapped_discrete")
})

0 comments on commit dbbcd43

Please sign in to comment.