tests/testthat/test_ion_bar_plot.R

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"))

})
EMSL-Computing/pspecterlib documentation built on Jan. 28, 2024, 8:13 p.m.