| 1 |
test_that("input validation works", { |
| 2 |
expect_error(jinjar_config(loader = 2)) |
| 3 |
expect_error(jinjar_config(block_open = "")) |
| 4 |
expect_error(jinjar_config(block_open = NA_character_)) |
| 5 |
expect_error(jinjar_config(trim_blocks = NA)) |
| 6 |
expect_snapshot(jinjar_config(block_open = "{{", variable_open = "{{"), error = TRUE) |
| 7 |
}) |
| 8 |
|
| 9 |
cli::test_that_cli("default works", { |
| 10 |
x <- jinjar_config() |
| 11 |
expect_s3_class(x, "jinjar_config") |
| 12 |
expect_null(x$loader) |
| 13 |
expect_snapshot(print(x)) |
| 14 |
}) |
| 15 |
|
| 16 |
cli::test_that_cli("string loader works", { |
| 17 |
test_path <- fs::path_home_r() |
| 18 |
|
| 19 |
x <- jinjar_config(test_path) |
| 20 |
expect_s3_class(x, "jinjar_config") |
| 21 |
expect_equal(x$loader, path_loader(test_path)) |
| 22 |
expect_snapshot( |
| 23 |
print(x), |
| 24 |
transform = function(x) gsub(test_path, "/path/to/templates", x, fixed = TRUE) |
| 25 |
) |
| 26 |
}) |