tests/testthat/test-statistics.R

context("Statistics")

with_mock_api({
  test_that("Statistics work", {
    s <- clstats('colors')
    expect_true(inherits(s, "clstats"), 
                label = "clstats class correct")
    expect_equal(attr(s, "clstat_type"), "colors", 
                 label = "clstat_type class correct")
    expect_gt(s, 1, label = "number is greater than 1")
  })
})

with_mock_api({
  test_that("Printing works", {
    s <- clstats('colors')
    s_output <- capture.output(s)
    
    expect_equal(length(s_output), 1,
                 label = "print output is correct length")
    expect_match(s_output, "Total colors:",
                 label = "correct label included")
  })
})

Try the colourlovers package in your browser

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

colourlovers documentation built on Jan. 13, 2021, 11:52 a.m.