context("test-calculate_reporting_period")
data <- system.file("testdata", "testdata-calculate_reporting_period.rds", package = "hisreportr") %>%
readRDS()
# test numeric variable
out <- hisreportr:::calculate_reporting_period(x = data,
disease = "ds-tb")
test_that("working correctly", {
expect_equal(nrow(out), nrow(data))
expect_true(ncol(out) - 1 == ncol(data))
expect_true("reporting_ds_period" %in% names(out))
expect_true(all(is.na(out$reporting_ds_period[is.na(out$starttre)])))
# ensure all reporting periods are retrospecive
expect_true(all(out$reporting_ds_period[!is.na(out$starttre)] >
lubridate::quarter(out$starttre[!is.na(out$starttre)],
with_year = TRUE)))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.