context("test: ion_bar_plot")
test_that("Testing ion bar plot plotting function", {
# Download required test files------------------------------------------------
BU_Match <- readRDS(system.file("testdata", "BU_Match.RDS", package = "pspecterlib"))
# Test ion bar plot input checks----------------------------------------------
# Matched peaks must be of the correct class
expect_error(
ion_bar_plot(data.frame(test = 1)),
"MatchedPeaks must be of the class matched_peaks generated by get_matched_peaks."
)
# Interactive must be a TRUE or FALSE
expect_error(
ion_bar_plot(BU_Match, "FALSE"),
"Interactive must be a single logical value TRUE or FALSE."
)
# Create an ion bar plot------------------------------------------------------
# Create a static plot
IonBar1 <- suppressWarnings(ion_bar_plot(BU_Match, NA))
expect_true(inherits(IonBar1, "ggplot"))
# Create an interactive plot
IonBar2 <- suppressWarnings(ion_bar_plot(BU_Match, TRUE))
expect_true(inherits(IonBar2, "plotly"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.