tests/testthat/test-update_themes.R

context('Check update_theme')


# Define custom theme -----------------------------------------------------
theme_xp_custom <- theme_xp_default()
theme_xp_custom$point_color <- 'green'
theme_xp_custom <- as.xpose.theme(theme_xp_custom)


# Tests start here --------------------------------------------------------

test_that('returns error on missing xpdb', {
  expect_error(update_themes())
})

test_that('returns identical xpdb if missing themes', {
  expect_identical(update_themes(xpdb = xpdb_ex_pk), xpdb_ex_pk)
})

test_that('full gg_themes are properly added', {
  expect_equal(ignore_attr = FALSE,
               update_themes(xpdb = xpdb_ex_pk, 
                             gg_theme = theme_bw2())$gg_theme, 
               theme_bw2(),
               check.attributes = FALSE,
               check.environment = FALSE
  )
})

test_that('message returned on bad gg_theme input', {
  expect_message(update_themes(xpdb = xpdb_ex_pk, 
                               gg_theme = theme_xp_default(),
                               quiet = FALSE))
})

test_that('full xp_themes are properly added', {
  expect_equal(update_themes(xpdb = xpdb_ex_pk,
                             xp_theme = theme_xp_xpose4())$xp_theme,
               theme_xp_xpose4(),
               check.attributes = FALSE,
               check.environment = FALSE)
})

test_that('parial xp_themes are properly added', {
  expect_equal(update_themes(xpdb = xpdb_ex_pk, 
                             xp_theme = c(point_color = 'green'))$xp_theme,
               theme_xp_custom,
               check.attributes = FALSE,
               check.environment = FALSE)
})

test_that('message on unnamed xp_theme input', {
  expect_message(update_themes(xpdb = xpdb_ex_pk, 
                               xp_theme = c('blue', 'dashed'), 
                               quiet = FALSE))
})

Try the xpose package in your browser

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

xpose documentation built on June 30, 2021, 9:07 a.m.