context("test: xic_plot")
test_that("Testing xic plotting function", {
# Download required test files------------------------------------------------
BU_XIC <- readRDS(system.file("testdata", "BU_XIC.RDS", package = "pspecterlib"))
# Test xic_plot input checks--------------------------------------------------
# XICobj must be an xic_pspecter object
expect_error(
xic_plot(data.frame(Test = 1)),
"XICobj must be a xic_pspecter object generated by get_xic."
)
# Smooth must be a true or false
expect_error(
xic_plot(BU_XIC, Smooth = "FALSE"),
"Smooth parameter must be either TRUE or FALSE."
)
# Interactive must be a true or false
expect_error(
xic_plot(BU_XIC, Interactive = NA),
"Interactive parameter must be either TRUE or FALSE."
)
# Create an xic plot----------------------------------------------------------
# Return a ggplot
plot1 <- suppressWarnings(xic_plot(BU_XIC, Smooth = TRUE, Interactive = FALSE))
expect_true(inherits(plot1, "ggplot"))
# Return a plotly
plot2 <- xic_plot(BU_XIC, Smooth = FALSE, Interactive = TRUE)
expect_true(inherits(plot2, "plotly"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.