Skip to content

Commit

Permalink
add minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Aug 14, 2024
1 parent 6491bce commit 02e8fe7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
14 changes: 7 additions & 7 deletions tests/testthat/test-cols_align.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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 <-
Expand Down
11 changes: 5 additions & 6 deletions tests/testthat/test-l_cols_align.R
Original file line number Diff line number Diff line change
@@ -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`,
Expand Down Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions tests/testthat/test-utils_render_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"))

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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() %>%
Expand All @@ -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() %>%
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 02e8fe7

Please sign in to comment.