tests/testthat/test-is_a_processed_spectra_list.R

# WARNING - Generated by {fusen} from dev/flat_utils.Rmd: do not edit by hand

foo <- list(
  "spectra" = list(MALDIquant::createMassSpectrum(1, 1)),
  "peaks" = list(MALDIquant::createMassPeaks(1, 1)),
  "metadata" = tibble::tibble(name = "foo")
)
test_that("is_a_processed_spectra_list works", {
  expect_true(
    is_a_processed_spectra_list(list(foo))
  )
  expect_true(
    is_a_processed_spectra_list(list(foo, foo))
  )
})
test_that("is_a_processed_spectra_list fails", {
  expect_error(
    is_a_processed_spectra_list(list(TRUE)),
    "The processed_spectra object is not a list of lists as expected!"
  )
  expect_error(
    is_a_processed_spectra_list(foo),
    "The processed_spectra object is not a list of lists as expected, but close enough!"
  )
  expect_error(
    is_a_processed_spectra_list(list(list(list(TRUE)))),
    "The list does not contain the three expected named objects"
  )
  expect_error(
    is_a_processed_spectra_list(
      list(list(
        "spectra" = list(TRUE),
        "peaks" = list(MALDIquant::createMassPeaks(1, 1)),
        "metadata" = tibble::tibble(name = "foo")
      ))
    ),
    "The 'spectra' list is not a MALDIquant::MassSpectrum object!"
  )
  expect_error(
    is_a_processed_spectra_list(
      list(list(
        "spectra" = list(MALDIquant::createMassSpectrum(1, 1)),
        "peaks" = list(TRUE),
        "metadata" = tibble::tibble(name = "foo")
      ))
    ),
    "The 'spectra' list is not a MALDIquant::MassPeaks object!"
  )
  expect_error(
    is_a_processed_spectra_list(
      list(list(
        "spectra" = list(MALDIquant::createMassSpectrum(1, 1)),
        "peaks" = list(MALDIquant::createMassPeaks(1, 1)),
        "metadata" = TRUE
      )),
      "not a tibble"
    )
  )
})

Try the maldipickr package in your browser

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

maldipickr documentation built on Sept. 13, 2024, 1:12 a.m.