tests/testthat/test-scales.R

context("test-scales")


test_that("which_pal_scale works", {
  
  auto <- which_pal_scale(
    mapping = ggplot2::aes(fill = Sepal.Length), 
    palette = "ggplot2", 
    data = iris
  )
  
  expect_length(auto, 2)
  expect_named(auto, c("scales", "args"))
  
  args <- which_pal_scale(
    mapping = ggplot2::aes(color = variable), 
    palette = "Blues", 
    color_type = "discrete"
  )
  
  expect_length(args$args, 1)
  expect_identical(args$scales, names(args$args))
  
  two <- which_pal_scale(
    mapping = ggplot2::aes(color = var1, fill = var2), 
    palette = "Blues", 
    color_type = "discrete",
    fill_type = "continuous"
  )
  
  expect_length(two$scales, 2)
})

Try the esquisse package in your browser

Any scripts or data that you put into this service are public.

esquisse documentation built on Sept. 18, 2024, 5:09 p.m.