diff --git a/tests/testthat/test-cols_align.R b/tests/testthat/test-cols_align.R index 750fb15c7a..c55e6a59e1 100644 --- a/tests/testthat/test-cols_align.R +++ b/tests/testthat/test-cols_align.R @@ -1,10 +1,3 @@ -# Create a data frame based on the internal `sp500.csv` -sp500 <- - read.csv( - system.file("extdata", "sp500.csv", package = "gt"), - stringsAsFactors = FALSE - ) - # Function to skip tests if Suggested packages not available on system check_suggests <- function() { skip_if_not_installed("rvest") @@ -105,6 +98,13 @@ test_that("cols_align() works correctly", { rvest::html_text() %>% expect_equal(colnames(mtcars_short)) + # Create a data frame based on the internal `sp500.csv` + sp500 <- + read.csv( + system.file("extdata", "sp500.csv", package = "gt"), + stringsAsFactors = FALSE + ) + # Create a `tbl_html` object with the `sp500` data # frame and `auto`-align all columns tbl_html <- diff --git a/tests/testthat/test-l_cols_align.R b/tests/testthat/test-l_cols_align.R index 80c4cd5482..dda20460cb 100644 --- a/tests/testthat/test-l_cols_align.R +++ b/tests/testthat/test-l_cols_align.R @@ -1,9 +1,3 @@ -# Create a data frame based on the internal `sp500.csv` -sp500 <- - read.csv( - system.file("extdata", "sp500.csv", package = "gt"), - stringsAsFactors = FALSE) - test_that("cols_align() works correctly", { # Create a `tbl_latex` object with `gt()`; the `mpg`, @@ -53,6 +47,11 @@ test_that("cols_align() works correctly", { # Expect a characteristic pattern expect_length(tbl_latex, 1) expect_match(tbl_latex, ".*begin\\{longtable\\}\\{lllllllllll\\}.*") + # Create a data frame based on the internal `sp500.csv` + sp500 <- + read.csv( + system.file("extdata", "sp500.csv", package = "gt"), + stringsAsFactors = FALSE) # Create a `tbl_latex` object with the `sp500` data # frame and `auto`-align all columns diff --git a/tests/testthat/test-utils_render_grid.R b/tests/testthat/test-utils_render_grid.R index 2b23c22339..97c85260be 100644 --- a/tests/testthat/test-utils_render_grid.R +++ b/tests/testthat/test-utils_render_grid.R @@ -10,7 +10,7 @@ has_class <- function(layout, class) { # Layout tests ------------------------------------------------------------ -test_that("create_caption_component_g creates captions", { +test_that("create_caption_component_g() creates captions", { df <- data.frame(x = 1:2, y = 3:4) @@ -27,7 +27,7 @@ test_that("create_caption_component_g creates captions", { expect_length(test$classes[[1]], 2) }) -test_that("create_heading_component_g creates headings", { +test_that("create_heading_component_g() creates headings", { df <- data.frame(x = 1:2, y = 3:4) @@ -57,7 +57,7 @@ test_that("create_heading_component_g creates headings", { expect_match(test$label, "gt_footnote_marks") }) -test_that("create_columns_component_g creates columns and spanners", { +test_that("create_columns_component_g() creates columns and spanners", { df <- data.frame(A = 1:2, B = 3:4, C = 5:6) gt <- gt(df) @@ -114,7 +114,7 @@ test_that("create_columns_component_g creates columns and spanners", { expect_snapshot(test) }) -test_that("group_headings_g creates appropriate group headings", { +test_that("group_headings_g() creates appropriate group headings", { df <- data.frame(x = 1:3, y = 4:6) @@ -151,7 +151,7 @@ test_that("group_headings_g creates appropriate group headings", { expect_null(test) }) -test_that("body_cells_g creates appropriate cells", { +test_that("body_cells_g() creates appropriate cells", { df <- data.frame(x = 1:3, y = 4:6, row = c("A", "B", "C")) @@ -196,7 +196,7 @@ test_that("body_cells_g creates appropriate cells", { ) }) -test_that("summary_rows_g creates appropriate cells for group summaries", { +test_that("summary_rows_g() creates appropriate cells for group summaries", { df <- data.frame(x = 1:3, y = 4:6) @@ -230,7 +230,7 @@ test_that("summary_rows_g creates appropriate cells for group summaries", { ) }) -test_that("summary_rows_g creates appropriate cells for grand summaries", { +test_that("summary_rows_g() creates appropriate cells for grand summaries", { df <- data.frame(x = 1:3, y = 4:6) @@ -259,7 +259,7 @@ test_that("summary_rows_g creates appropriate cells for grand summaries", { ) }) -test_that("create_body_component_g places group summaries correctly", { +test_that("create_body_component_g() places group summaries correctly", { df <- data.frame(x = 1:3, y = 4:6) @@ -293,7 +293,7 @@ test_that("create_body_component_g places group summaries correctly", { expect_equal(test$bottom[summary], rep(c(2, 6), each = 3)) }) -test_that("create_body_component_g places grand summaries correctly", { +test_that("create_body_component_g() places grand summaries correctly", { df <- data.frame(x = 1:3, y = 4:6) @@ -316,7 +316,7 @@ test_that("create_body_component_g places grand summaries correctly", { expect_equal(test$bottom[summary], rep(4, each = 3)) }) -test_that("create_source_notes_component_g creates source notes", { +test_that("create_source_notes_component_g() creates source notes", { gt <- data.frame(x = 1:3, y = 4:6) %>% gt() %>% @@ -339,7 +339,7 @@ test_that("create_source_notes_component_g creates source notes", { expect_equal(test$label, "Multi line") }) -test_that("create_footnotes_component_g creates footnotes", { +test_that("create_footnotes_component_g() creates footnotes", { gt <- data.frame(x = 1:3, y = 4:6) %>% gt() %>% @@ -536,7 +536,7 @@ test_that("Classes and styles are parsed correctly", { # Feature tests ----------------------------------------------------------- -test_that("as_gtable renders svg entries", { +test_that("as_gtable() renders svg entries", { df <- data.frame( x = 1,