test_that("make_industry_table() makes the industry table", {
# Clear any leftover environmental variables from earlier tests
Sys.unsetenv("R_DJPRLABOURDASH_TABLEDEST")
i_t <- make_industry_table(
data = filter_dash_data(
c(
"A84601662A",
"A84601680F",
"A84601683L",
"A84601686V",
"A84601665J",
"A84601704L",
"A84601707V",
"A84601710J",
"A84601638A",
"A84601653X",
"A84601689A",
"A84601656F",
"A84601713R",
"A84601668R",
"A84601695W",
"A84601698C",
"A84601650T",
"A84601671C",
"A84601641R",
"A84601716W")
),
row_order = c(
"A84601662A",
"A84601680F",
"A84601683L",
"A84601686V",
"A84601665J",
"A84601704L",
"A84601707V",
"A84601710J",
"A84601638A",
"A84601653X",
"A84601689A",
"A84601656F",
"A84601713R",
"A84601668R",
"A84601695W",
"A84601698C",
"A84601650T",
"A84601671C",
"A84601641R",
"A84601716W")
)
expect_s3_class(i_t, "flextable")
i_t_header_row <- as.character(i_t$header$dataset[1, ])
expect_equal(
i_t_header_row,
c(
"",
"Current figures",
"Current figures",
"Change in latest period",
"Change in past year",
"Change since COVID-19",
"Change during govt"
)
)
i_t_final_col <- i_t$body$dataset$`SINCE NOV 2014`
expect_type(i_t_final_col, "character")
expect_true(all(nchar(i_t_final_col) >= 1))
})
test_that("make_industry_table()'s output has not changed", {
data <- djprlabourdash:::filter_dash_data(
c(
"A84601662A",
"A84601680F",
"A84601683L",
"A84601686V",
"A84601665J",
"A84601704L",
"A84601707V",
"A84601710J",
"A84601638A",
"A84601653X",
"A84601689A",
"A84601656F",
"A84601713R",
"A84601668R",
"A84601695W",
"A84601698C",
"A84601650T",
"A84601671C",
"A84601641R",
"A84601716W")
) %>%
dplyr::filter(.data$date <= as.Date("2022-05-02"))
to_may_2022 <- data %>%
dplyr::mutate(
indicator = dplyr::if_else(.data$industry != "",
.data$industry,
"Victoria - all industries")
)
table <- make_industry_table(to_may_2022,
row_order = c(
"A84601662A",
"A84601680F",
"A84601683L",
"A84601686V",
"A84601665J",
"A84601704L",
"A84601707V",
"A84601710J",
"A84601638A",
"A84601653X",
"A84601689A",
"A84601656F",
"A84601713R",
"A84601668R",
"A84601695W",
"A84601698C",
"A84601650T",
"A84601671C",
"A84601641R",
"A84601716W"),
highlight_rows = "A84601662A"
)
expect_s3_class(table, "flextable")
table_df <- table$body$dataset
expect_s3_class(table_df, "data.frame")
expect_equal(
names(table_df),
c(
" ",
"SERIES_ID",
"MAY 2022",
"% OF TOTAL",
"LAST 3 YEARS",
"SINCE FEB 2022",
"SINCE MAY 2021",
"SINCE FEB 2020",
"SINCE NOV 2014"
)
)
table_without_sparklines <- dplyr::select(
table_df,
-`LAST 3 YEARS`
)
expect_snapshot_output(table_without_sparklines)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.