tests/testthat/test_coverage_bar_plot.R

context("test: coverage_bar_plot")

test_that("Testing coverage bar plotting function", {

  # Download required test files------------------------------------------------

  PC <- readRDS(system.file("testdata", "PeptideCoverage.RDS", package = "pspecterlib"))

  # Test coverage bar plot input checks-----------------------------------------

  # Peptide coverage must be of the correct class
  expect_error(
    coverage_bar_plot(data.frame(test = 1)),
    "PeptideCoverage must be an object of the peptide_coverage class generated by get_peptide_coverage."
  )

  # Interactive should be a true or false
  expect_error(
    coverage_bar_plot(PC, Interactive = "NA"),
    "Interactive must be a single logical value TRUE or FALSE."
  )

  # Create an coverage bar plot-------------------------------------------------

  # Make an interactive bar plot
  theBarplot <- coverage_bar_plot(PC, TRUE)
  expect_true(inherits(theBarplot, "plotly"))

  # Make a static bar plot with the NA option
  staticBar <- coverage_bar_plot(PC, NA)
  expect_true(inherits(staticBar, "ggplot"))

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