tests/testthat/test-r-onerm.R

context("test-r-onerm")

testthat::test_that("Using Epley method with 80 kg and 10 reps is 106.67", {
  repmax <- oneRM(10, 80, method = "Epley", plot = FALSE)
  expect_equal(repmax, 106.67)
})

testthat::test_that("With one method, plot can never be True", {
  expect_error(oneRM(10, 80, method = "Epley", plot = TRUE))
})

testthat::test_that("Reps can not be set to 1", {
  expect_error(oneRM(1, 80, method = "All", plot = FALSE))
})

testthat::test_that("Reps can not be set to a float", {
  expect_error(oneRM(2.5, 80, method = "All", plot = FALSE))
})

testthat::test_that("Reps can not be set to >12", {
  expect_error(oneRM(30, 80, method = "All", plot = FALSE))
})

testthat::test_that("The method has to be recognized", {
  expect_error(oneRM(8, 80, method = "NotAMethod", plot = FALSE))
})

testthat::test_that("The method `All` and plot = FALSE outputs a table", {
  repmax <- oneRM(10, 80, method = "All", plot = FALSE)
  # Expect 8 rows
  expect_output(str(repmax), "8 obs")
  # Expect 3 columns
  expect_output(str(repmax), "3 variables")
  expect_equal(class(repmax), "data.frame")
  expect_named(repmax, c("Method", "Values", "Mean"))
})

testthat::test_that("The method `All` and plot = TRUE outputs a ggplot", {
  p <- oneRM(10, 80, method = "All", plot = TRUE)
  expect_true(ggplot2::is.ggplot(p))
  expect_equal(length(p$layers), 4)
  expect_equal(p$labels$y, "Weight (kg)")
  expect_equal(p$labels$x, NULL)
})

testthat::test_that("plotEstimates plots 8 estimates and estimate 1 is Brzycki", {
  p <- plotEstimates(10, 80)
  expect_true(ggplot2::is.ggplot(p))
  expect_equal(length(p$layers), 8)
  expect_equal(p$layers[[1]]$mapping$colour, "Brzycki")
})
MarijnJABoer/HeavySetR documentation built on May 22, 2019, 5:31 p.m.