diff --git a/R/table_index.R b/R/table_index.R index 7c6d087e..5c21a8ac 100644 --- a/R/table_index.R +++ b/R/table_index.R @@ -151,7 +151,7 @@ table_index <- function( } create_rda( - object = final[[1]], + object = final, # get name of function and remove "table_" from it topic_label = gsub("table_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)), fig_or_table = "table", diff --git a/R/table_landings.R b/R/table_landings.R index c8755267..7f711c9a 100644 --- a/R/table_landings.R +++ b/R/table_landings.R @@ -167,7 +167,7 @@ table_landings <- function( insert_kqs(landings.units, dir = tables_dir) create_rda( - object = final[[1]], + object = final, # get name of function and remove "table_" from it topic_label = gsub("table_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)), fig_or_table = "table", diff --git a/tests/testthat/test-table_index.R b/tests/testthat/test-table_index.R index 9fa9563e..9204bbb1 100644 --- a/tests/testthat/test-table_index.R +++ b/tests/testthat/test-table_index.R @@ -32,31 +32,3 @@ test_that("table_index generates plots without errors", { # "gt_tbl" # ) }) - -# test_that("rda file made when indicated", { -# # export rda -# table_index( -# dat = stockplotr::example_data, -# interactive = FALSE, -# make_rda = TRUE, -# tables_dir = getwd() -# ) - -# # load the rda file and check that it contains the expected object -# load(fs::path(getwd(), "tables", "index_table.rda")) -# # expect rda contains three objects: table, caption, and latex table -# expect_false( -# is.null(rda$table) -# ) -# expect_false( -# is.null(rda$caption) -# ) -# expect_false( -# is.null(rda$latex_table) -# ) - -# expect_true(rda$caption == "Calculated index of abundance and corresponding CVs for the fleets and surveys identified in the column headers. ") - -# # erase temporary testing files -# check_and_remove_tmp_files("index_table.rda", figs_or_tables="tables") -# }) diff --git a/tests/testthat/test-table_landings.R b/tests/testthat/test-table_landings.R index 04f37761..0db427d4 100644 --- a/tests/testthat/test-table_landings.R +++ b/tests/testthat/test-table_landings.R @@ -37,28 +37,6 @@ test_that("table_landings generates plots without errors", { # ) }) -# test_that("rda file made when indicated", { -# # export rda -# table_landings( -# dat = stockplotr::example_data, -# unit_label = "mt", -# era = NULL, -# interactive = FALSE, -# module = "CATCH", -# make_rda = TRUE, -# tables_dir = getwd() -# ) - -# # expect that both tables dir and the landings_table.rda file exist -# expect_true(dir.exists(fs::path(getwd(), "tables"))) -# expect_true(file.exists(fs::path(getwd(), "tables", "landings_table.rda"))) - -# # erase temporary testing files -# file.remove(fs::path(getwd(), "captions_alt_text.csv")) -# file.remove(fs::path(getwd(), "key_quantities.csv")) -# unlink(fs::path(getwd(), "tables"), recursive = T) -# }) - test_that("table_landings generates error with incorrect module", { # expect error # Need to test this -- not exactly the right test/result @@ -73,33 +51,4 @@ test_that("table_landings generates error with incorrect module", { tables_dir = getwd() ) ) -}) - - -# test_that("rda file made when indicated", { -# # export rda -# table_landings( -# dat = stockplotr::example_data, -# interactive = FALSE, -# make_rda = TRUE, -# tables_dir = getwd() -# ) - -# # load the rda file and check that it contains the expected object -# load(fs::path(getwd(), "tables", "landings_table.rda")) -# # expect rda contains three objects: table, caption, and latex table -# expect_false( -# is.null(rda$table) -# ) -# expect_false( -# is.null(rda$caption) -# ) -# expect_false( -# is.null(rda$latex_table) -# ) - -# expect_true(rda$caption == "Landed catch by fleet and year in (mt).") - -# # erase temporary testing files -# check_and_remove_tmp_files("landings_table.rda", figs_or_tables="tables") -# }) +}) \ No newline at end of file