Skip to content

Commit

Permalink
update flextable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanChaltiel committed Aug 24, 2024
1 parent 165f555 commit 56103c2
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 82 deletions.
156 changes: 78 additions & 78 deletions tests/testthat/_snaps/flextable.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@
Code
ct2 %>% as_flextable() %>% get_header_df()
Output
label variable am=auto & vs=straight am=manual & vs=straight
1 label variable vs=straight vs=straight
2 label variable am=auto am=manual
label variable am=auto & vs=straight am=manual & vs=straight
1 Engine Engine straight straight
2 Transmission Transmission auto manual
am=auto & vs=vshaped am=manual & vs=vshaped am=auto & vs=NA am=manual & vs=NA
1 vs=vshaped vs=vshaped vs=NA vs=NA
2 am=auto am=manual am=auto am=manual
1 vshaped vshaped NA NA
2 auto manual auto manual
Code
ct3 %>% as_flextable() %>% get_header_df()
Output
label variable vs=straight & cyl3=FALSE & am=auto
1 label variable am=auto
2 label variable cyl3=FALSE
3 label variable vs=straight
label variable vs=straight & cyl3=FALSE & am=auto
1 Transmission Transmission auto
2 cyl3 cyl3 FALSE
3 Engine Engine straight
vs=vshaped & cyl3=FALSE & am=auto vs=NA & cyl3=FALSE & am=auto
1 am=auto am=auto
2 cyl3=FALSE cyl3=FALSE
3 vs=vshaped vs=NA
1 auto auto
2 FALSE FALSE
3 vshaped NA
vs=straight & cyl3=NA & am=auto vs=vshaped & cyl3=NA & am=auto
1 am=auto am=auto
2 cyl3=NA cyl3=NA
3 vs=straight vs=vshaped
1 auto auto
2 NA NA
3 straight vshaped
vs=NA & cyl3=NA & am=auto vs=straight & cyl3=FALSE & am=manual
1 am=auto am=manual
2 cyl3=NA cyl3=FALSE
3 vs=NA vs=straight
1 auto manual
2 NA FALSE
3 NA straight
vs=vshaped & cyl3=FALSE & am=manual vs=NA & cyl3=FALSE & am=manual
1 am=manual am=manual
2 cyl3=FALSE cyl3=FALSE
3 vs=vshaped vs=NA
1 manual manual
2 FALSE FALSE
3 vshaped NA
vs=straight & cyl3=NA & am=manual vs=vshaped & cyl3=NA & am=manual
1 am=manual am=manual
2 cyl3=NA cyl3=NA
3 vs=straight vs=vshaped
1 manual manual
2 NA NA
3 straight vshaped
vs=NA & cyl3=NA & am=manual
1 am=manual
2 cyl3=NA
3 vs=NA
1 manual
2 NA
3 NA

# header by_header (monoby)

Expand Down Expand Up @@ -126,7 +126,7 @@

Code
ct2 %>% as_flextable(header_show_n = TRUE, header_show_n_pattern = "{.col_key}:\n{.col_val}\n(N={.n})",
remove_header_keys = T) %>% get_header_df()
remove_header_keys = FALSE) %>% get_header_df()
Output
label variable am=auto & vs=straight am=manual & vs=straight
1 label variable vs:\nstraight\n(N=9) vs:\nstraight\n(N=9)
Expand All @@ -141,55 +141,55 @@
# header header_show_n+remove_header_keys

Code
ct2 %>% as_flextable(header_show_n = TRUE, remove_header_keys = TRUE) %>%
ct2 %>% as_flextable(header_show_n = TRUE, remove_header_keys = FALSE) %>%
get_header_df()
Output
label variable am=auto & vs=straight am=manual & vs=straight
1 label variable straight (N=9) straight (N=9)
2 label variable auto (N=2) manual (N=7)
1 label variable vs=straight (N=9) vs=straight (N=9)
2 label variable am=auto (N=2) am=manual (N=7)
am=auto & vs=vshaped am=manual & vs=vshaped am=auto & vs=NA am=manual & vs=NA
1 vshaped (N=15) vshaped (N=15) NA (N=8) NA (N=8)
2 auto (N=9) manual (N=6) auto (N=8) manual (N=0)
1 vs=vshaped (N=15) vs=vshaped (N=15) vs=NA (N=8) vs=NA (N=8)
2 am=auto (N=9) am=manual (N=6) am=auto (N=8) am=manual (N=0)

# header remove_header_keys

Code
ct1 %>% as_flextable(remove_header_keys = T) %>% get_header_df()
ct1 %>% as_flextable(remove_header_keys = FALSE) %>% get_header_df()
Output
label variable auto manual
1 label variable Transmission Transmission
2 label variable auto manual
Code
ct3 %>% as_flextable(remove_header_keys = T) %>% get_header_df()
ct3 %>% as_flextable(remove_header_keys = FALSE) %>% get_header_df()
Output
label variable vs=straight & cyl3=FALSE & am=auto
1 label variable auto
2 label variable FALSE
3 label variable straight
1 label variable am=auto
2 label variable cyl3=FALSE
3 label variable vs=straight
vs=vshaped & cyl3=FALSE & am=auto vs=NA & cyl3=FALSE & am=auto
1 auto auto
2 FALSE FALSE
3 vshaped NA
1 am=auto am=auto
2 cyl3=FALSE cyl3=FALSE
3 vs=vshaped vs=NA
vs=straight & cyl3=NA & am=auto vs=vshaped & cyl3=NA & am=auto
1 auto auto
2 NA NA
3 straight vshaped
1 am=auto am=auto
2 cyl3=NA cyl3=NA
3 vs=straight vs=vshaped
vs=NA & cyl3=NA & am=auto vs=straight & cyl3=FALSE & am=manual
1 auto manual
2 NA FALSE
3 NA straight
1 am=auto am=manual
2 cyl3=NA cyl3=FALSE
3 vs=NA vs=straight
vs=vshaped & cyl3=FALSE & am=manual vs=NA & cyl3=FALSE & am=manual
1 manual manual
2 FALSE FALSE
3 vshaped NA
1 am=manual am=manual
2 cyl3=FALSE cyl3=FALSE
3 vs=vshaped vs=NA
vs=straight & cyl3=NA & am=manual vs=vshaped & cyl3=NA & am=manual
1 manual manual
2 NA NA
3 straight vshaped
1 am=manual am=manual
2 cyl3=NA cyl3=NA
3 vs=straight vs=vshaped
vs=NA & cyl3=NA & am=manual
1 manual
2 NA
3 NA
1 am=manual
2 cyl3=NA
3 vs=NA

# header header_show_n

Expand Down Expand Up @@ -223,32 +223,32 @@
Code
ct3 %>% af(header_show_n = TRUE) %>% get_header_df()
Output
label variable vs=straight & cyl3=FALSE & am=auto
1 label variable am=auto (N=19)
2 label variable cyl3=FALSE (N=17)
3 label variable vs=straight (N=1)
label variable vs=straight & cyl3=FALSE & am=auto
1 Transmission Transmission auto (N=19)
2 cyl3 cyl3 FALSE (N=17)
3 Engine Engine straight (N=1)
vs=vshaped & cyl3=FALSE & am=auto vs=NA & cyl3=FALSE & am=auto
1 am=auto (N=19) am=auto (N=19)
2 cyl3=FALSE (N=17) cyl3=FALSE (N=17)
3 vs=vshaped (N=9) vs=NA (N=7)
1 auto (N=19) auto (N=19)
2 FALSE (N=17) FALSE (N=17)
3 vshaped (N=9) NA (N=7)
vs=straight & cyl3=NA & am=auto vs=vshaped & cyl3=NA & am=auto
1 am=auto (N=19) am=auto (N=19)
2 cyl3=NA (N=2) cyl3=NA (N=2)
3 vs=straight (N=1) vs=vshaped (N=0)
1 auto (N=19) auto (N=19)
2 NA (N=2) NA (N=2)
3 straight (N=1) vshaped (N=0)
vs=NA & cyl3=NA & am=auto vs=straight & cyl3=FALSE & am=manual
1 am=auto (N=19) am=manual (N=13)
2 cyl3=NA (N=2) cyl3=FALSE (N=10)
3 vs=NA (N=1) vs=straight (N=6)
1 auto (N=19) manual (N=13)
2 NA (N=2) FALSE (N=10)
3 NA (N=1) straight (N=6)
vs=vshaped & cyl3=FALSE & am=manual vs=NA & cyl3=FALSE & am=manual
1 am=manual (N=13) am=manual (N=13)
2 cyl3=FALSE (N=10) cyl3=FALSE (N=10)
3 vs=vshaped (N=4) vs=NA (N=0)
1 manual (N=13) manual (N=13)
2 FALSE (N=10) FALSE (N=10)
3 vshaped (N=4) NA (N=0)
vs=straight & cyl3=NA & am=manual vs=vshaped & cyl3=NA & am=manual
1 am=manual (N=13) am=manual (N=13)
2 cyl3=NA (N=3) cyl3=NA (N=3)
3 vs=straight (N=1) vs=vshaped (N=2)
1 manual (N=13) manual (N=13)
2 NA (N=3) NA (N=3)
3 straight (N=1) vshaped (N=2)
vs=NA & cyl3=NA & am=manual
1 am=manual (N=13)
2 cyl3=NA (N=3)
3 vs=NA (N=0)
1 manual (N=13)
2 NA (N=3)
3 NA (N=0)

8 changes: 4 additions & 4 deletions tests/testthat/test-flextable.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test_that("header header_show_n+pattern", {
ct2 %>%
as_flextable(header_show_n=TRUE,
header_show_n_pattern="{.col_key}:\n{.col_val}\n(N={.n})",
remove_header_keys=T) %>%
remove_header_keys=FALSE) %>%
get_header_df()
})
})
Expand All @@ -68,7 +68,7 @@ test_that("header header_show_n+remove_header_keys", {
expect_snapshot({
ct2 %>%
as_flextable(header_show_n=TRUE,
remove_header_keys=TRUE) %>%
remove_header_keys=FALSE) %>%
get_header_df()
})
})
Expand All @@ -79,8 +79,8 @@ test_that("header header_show_n+remove_header_keys", {

test_that("header remove_header_keys", {
expect_snapshot({
ct1 %>% as_flextable(remove_header_keys=T) %>% get_header_df()
ct3 %>% as_flextable(remove_header_keys=T) %>% get_header_df()
ct1 %>% as_flextable(remove_header_keys=FALSE) %>% get_header_df()
ct3 %>% as_flextable(remove_header_keys=FALSE) %>% get_header_df()
})
})

Expand Down

0 comments on commit 56103c2

Please sign in to comment.