Skip to content

Commit

Permalink
add unit test for alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ayogasekaram committed Nov 1, 2024
1 parent b222480 commit 1d13d04
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/testthat/_snaps/show_header_names.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,18 @@
* These values may be dynamically placed into headers (and other locations).
i Review the `modify_header()` (`?gtsummary::modify()`) help for examples.

# show_header_names() has all values aligned

Code
show_header_names(test_table)
Output
Column Name Header level* N* n* p*
label "**Primary System Organ Class** \n    **Reported Term for the Adverse Event**" 254 <int>
stat_1 "**Placebo** \nN = 86" Placebo <chr> 254 <int> 86 <int> 0.339 <dbl>
stat_2 "**Xanomeline High Dose** \nN = 84" Xanomeline High Dose <chr> 254 <int> 84 <int> 0.331 <dbl>
stat_3 "**Xanomeline Low Dose** \nN = 84" Xanomeline Low Dose <chr> 254 <int> 84 <int> 0.331 <dbl>
Message
* These values may be dynamically placed into headers (and other locations).
i Review the `modify_header()` (`?gtsummary::modify()`) help for examples.

14 changes: 14 additions & 0 deletions tests/testthat/test-show_header_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,17 @@ test_that("show_header_names() returns single class value", {
test_table |> show_header_names()
)
})


test_that("show_header_names() has all values aligned", {
test_table <- tbl_hierarchical(
data = cards::ADAE,
variables = c(AESOC, AETERM),
by = TRTA,
denominator = cards::ADSL |> mutate(TRTA = ARM),
id = USUBJID
)
expect_snapshot(
test_table |> show_header_names()
)
})

0 comments on commit 1d13d04

Please sign in to comment.