Skip to content

Commit

Permalink
Added test for balance and summary snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
jpavlich authored and davidsantiagoquevedo committed Jul 22, 2024
1 parent 564bc27 commit 1d3413a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/match_cohort/balance_all.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"","u","v","smd"
"age",42.4760479041916,44.748502994012,0.122719796315446
"sex_F",0.544910179640719,0.544910179640719,0
"sex_M",0.455089820359281,0.455089820359281,0
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/match_cohort/balance_match.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"","u","v","smd"
"age",42.4760479041916,44.748502994012,0.122719796315446
"sex_F",0.544910179640719,0.544910179640719,0
"sex_M",0.455089820359281,0.455089820359281,0
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/match_cohort/summary.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"","u","v","smd"
"age",42.4760479041916,44.748502994012,0.122719796315446
"sex_F",0.544910179640719,0.544910179640719,0
"sex_M",0.455089820359281,0.455089820359281,0
17 changes: 12 additions & 5 deletions tests/testthat/test-match_cohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ test_that("`match_cohort`: test for input validation", {
})

#### Snapshot for summary
# test_that("`match_cohort`: summary snapshot", { #nolint
# # snapshot for summary
# summ <- capture.output(summary.match(matching)) #nolint
# expect_snapshot(summ) #nolint
# })
test_that("`match_cohort`: summary snapshot", { # nolint
for (column in c("balance_all", "balance_match", "summary")) {
expect_similar_dataframes(
column, matching$balance_match,
list(
u = equal_with_tolerance(),
v = equal_with_tolerance(),
smd = equal_with_tolerance()
)
)
}
})

0 comments on commit 1d3413a

Please sign in to comment.