Skip to content

Commit 0b70dfe

Browse files
Update tests for fns
1 parent e13e0fa commit 0b70dfe

File tree

6 files changed

+2464
-15
lines changed

6 files changed

+2464
-15
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Imports:
2929
ggplot2,
3030
glue,
3131
readr,
32-
reshape2,
3332
rlang,
33+
scales,
3434
tidyr
3535
Suggests:
3636
knitr,

tests/testthat/_snaps/plotting/plot-age-patterns.svg

Lines changed: 1193 additions & 0 deletions
Loading

tests/testthat/_snaps/plotting/a-blank-plot.svg renamed to tests/testthat/_snaps/plotting/plot-demography-alignment.svg

File renamed without changes.

tests/testthat/_snaps/plotting/plot-global-burden-decades.svg

Lines changed: 1187 additions & 0 deletions
Loading

tests/testthat/test-plotting.R

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,53 @@ test_that("plot_compare_demography() works", {
88

99
checkmate::expect_class(p, "ggplot")
1010

11-
vdiffr::expect_doppelganger("A blank plot", p)
11+
vdiffr::expect_doppelganger("plot_demography_alignment", p)
12+
})
13+
14+
test_that("plot_age_patterns() works", {
15+
burden <- eg_burden_template
16+
burden <- prep_plot_age(burden)
17+
18+
# manually set values as template default is NA, prevents ggplot warnings
19+
burden$value_millions <- 1.0
20+
21+
p <- plot_age_patterns(burden, 1)
22+
23+
checkmate::expect_class(p, "ggplot")
24+
25+
vdiffr::expect_doppelganger("plot_age_patterns", p)
26+
})
27+
28+
test_that("plot_global_burden_decades() works", {
29+
burden <- eg_burden_template
30+
year_max <- 2100
31+
burden <- prep_plot_burden_decades(burden, year_max)
32+
33+
# manually set values as template default is NA, prevents ggplot warnings
34+
burden$value_millions <- 1.0
35+
36+
p <- plot_global_burden_decades(burden, 1)
37+
38+
checkmate::expect_class(p, "ggplot")
39+
40+
vdiffr::expect_doppelganger("plot_global_burden_decades", p)
41+
})
42+
43+
test_that("plot_global_burden_decades() works", {
44+
burden <- eg_burden_template
45+
burden <- prep_plot_global_burden(burden)
46+
47+
# NOTE: expected use case is to loop over nested column DFs
48+
# set values to a dummy placeholder
49+
burden$burden_data[[1]]$value_millions <- 1
50+
51+
p <- plot_global_burden(
52+
burden$burden_data[[1]],
53+
burden$burden_outcome[[1]],
54+
1
55+
)
56+
57+
checkmate::expect_class(p, "ggplot")
58+
59+
vdiffr::expect_doppelganger("plot_global_burden", p)
1260
})

tests/testthat/test-plotting_prep.R

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,54 @@ test_that("prep_plot_demography() works ", {
1111
)
1212
})
1313

14-
skip("Skipped while tests are written")
1514
test_that("prep_plot_age() works ", {
16-
checkmate::expect_tibble(
17-
prep_plot_age(x)
15+
burden <- eg_burden_template
16+
expected_colnames <- c("scenario", "burden_outcome", "age", "value_millions")
17+
x <- prep_plot_age(burden)
18+
19+
checkmate::expect_tibble(x)
20+
checkmate::expect_names(
21+
colnames(x),
22+
permutation.of = expected_colnames
1823
)
1924
})
2025

2126
test_that("prep_plot_burden_decades() works ", {
22-
checkmate::expect_tibble(
23-
prep_plot_burden_decades(x)
27+
burden <- eg_burden_template
28+
year_max <- 2100
29+
x <- prep_plot_burden_decades(burden, year_max)
30+
31+
expected_colnames <- c(
32+
"scenario",
33+
"burden_outcome",
34+
"decade_label",
35+
"value_millions"
36+
)
37+
checkmate::expect_tibble(x)
38+
checkmate::expect_names(
39+
colnames(x),
40+
permutation.of = expected_colnames
2441
)
2542
})
2643

44+
2745
test_that("prep_plot_global_burden() works ", {
28-
checkmate::expect_tibble(
29-
prep_plot_global_burden(x)
46+
burden <- eg_burden_template
47+
x <- prep_plot_global_burden(burden)
48+
49+
expected_colnames <- c("burden_outcome", "burden_data")
50+
51+
checkmate::expect_tibble(x, types = c("character", "list"))
52+
checkmate::expect_names(
53+
colnames(x),
54+
permutation.of = expected_colnames
3055
)
3156
})
3257

3358
test_that("prep_plot_coverage_set() works ", {
34-
checkmate::expect_tibble(
35-
prep_plot_coverage_set(x)
36-
)
59+
skip("TODO: Determine where coverage set data is generated")
3760
})
3861

3962
test_that("prep_plot_fvp() works ", {
40-
checkmate::expect_tibble(
41-
prep_plot_fvp(x)
42-
)
63+
skip("TODO: Fix how FVP data is generated")
4364
})

0 commit comments

Comments
 (0)