diff --git a/R/serocalculator_example.R b/R/serocalculator_example.R index 357b6c58..d07917f1 100644 --- a/R/serocalculator_example.R +++ b/R/serocalculator_example.R @@ -16,8 +16,8 @@ #' serocalculator_example("example_pop_data.csv") serocalculator_example <- function(file = NULL) { if (is.null(file)) { - dir(system.file("extdata", package = "serocalculator")) + dir(fs::path_package("extdata", package = "serocalculator")) } else { - system.file("extdata", file, package = "serocalculator", mustWork = TRUE) + fs::path_package("extdata", file, package = "serocalculator") } } diff --git a/tests/testthat/test-serocalculator_example.R b/tests/testthat/test-serocalculator_example.R index 8849056e..344e4dfb 100644 --- a/tests/testthat/test-serocalculator_example.R +++ b/tests/testthat/test-serocalculator_example.R @@ -1,3 +1,14 @@ -test_that("multiplication works", { - expect_equal(2 * 2, 4) +test_that("`serocalculator_example()` works", { + + path1 = serocalculator_example("example_pop_data.csv") + path2 = fs::path_package(package = "serocalculator", + "extdata/example_pop_data.csv") + expect_equal(path1, path2) + + + files1 = serocalculator_example() + files2 = "example_pop_data.csv" + + expect_equal(files1, files2) + })