From 1d13d043f2c745880eb5f2bf2da3e3bc1e767690 Mon Sep 17 00:00:00 2001 From: ayogasekaram Date: Fri, 1 Nov 2024 18:35:57 +0000 Subject: [PATCH] add unit test for alignment --- tests/testthat/_snaps/show_header_names.md | 15 +++++++++++++++ tests/testthat/test-show_header_names.R | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/testthat/_snaps/show_header_names.md b/tests/testthat/_snaps/show_header_names.md index b8e5f5ee9..aeed2be5d 100644 --- a/tests/testthat/_snaps/show_header_names.md +++ b/tests/testthat/_snaps/show_header_names.md @@ -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 + stat_1 "**Placebo** \nN = 86" Placebo 254 86 0.339 + stat_2 "**Xanomeline High Dose** \nN = 84" Xanomeline High Dose 254 84 0.331 + stat_3 "**Xanomeline Low Dose** \nN = 84" Xanomeline Low Dose 254 84 0.331 + + Message + * These values may be dynamically placed into headers (and other locations). + i Review the `modify_header()` (`?gtsummary::modify()`) help for examples. + diff --git a/tests/testthat/test-show_header_names.R b/tests/testthat/test-show_header_names.R index 64d88d5f7..53ff89fc6 100644 --- a/tests/testthat/test-show_header_names.R +++ b/tests/testthat/test-show_header_names.R @@ -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() + ) +})