Skip to content

Commit

Permalink
[tests] test styles across
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Dec 12, 2023
1 parent 882dc66 commit 449d3fc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/testthat/test-class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,23 @@ test_that("wb_add_style() is a wrapper", {
})


# wb_add_style_across() ---------------------------------------------------

test_that("wb_add_style() is a wrapper", {

wb <- wb_workbook() %>%
wb_add_worksheet() %>%
wb_add_fill(dims = "C3", color = wb_color("yellow"))

expect_wrapper(
"add_style_across",
wb = wb,
params = list(from = "C3", cols = "C:D", rows = 3:4)
)

})


# wb_get_cell_style() -----------------------------------------------------

test_that("wb_get_cell_style() is a wrapper", {
Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-wb_styles.R
Original file line number Diff line number Diff line change
Expand Up @@ -836,3 +836,27 @@ test_that("initialized styles remain available", {
expect_equal(exp, got)

})

test_that("apply styles across columns and rows", {

wb <- wb_workbook() %>%
wb_add_worksheet() %>%
wb_add_fill(dims = "C3", color = wb_color("yellow")) %>%
wb_add_style_across(from = "C3", cols = "C:D", rows = 3:4)

exp <- c(
"<col min=\"1\" max=\"2\" width=\"8.43\"/>",
"<col min=\"3\" max=\"4\" style=\"1\" width=\"8.43\"/>"
)
got <- wb$worksheets[[1]]$cols_attr
expect_equal(exp, got)

exp <- data.frame(
customFormat = c("1", "1"),
r = c("3", "4"),
s = c("1", "1")
)
got <- wb$worksheets[[1]]$sheet_data$row_attr[c("customFormat", "r", "s")]
expect_equal(exp, got)

})

0 comments on commit 449d3fc

Please sign in to comment.