diff --git a/tests/testthat/_snaps/xwalk.md b/tests/testthat/_snaps/xwalk.md new file mode 100644 index 0000000..61c4f6d --- /dev/null +++ b/tests/testthat/_snaps/xwalk.md @@ -0,0 +1,16 @@ +# xwalk functions work + + Code + acs_data_interp + Output + # A tibble: 1 x 22 + NAME variable column_id table_id estimate moe perc_estimate perc_moe + + 1 9504 B01003_001 B01003001 B01003 2748 272 NA NA + # i 14 more variables: geography , table_title , + # simple_table_title , subject_area , universe , + # denominator_column_id , topics , line_number , + # column_title , indent , parent_column_id , + # denominator_estimate , denominator_moe , + # denominator_column_title + diff --git a/tests/testthat/test-xwalk.R b/tests/testthat/test-xwalk.R new file mode 100644 index 0000000..2a23228 --- /dev/null +++ b/tests/testthat/test-xwalk.R @@ -0,0 +1,34 @@ +test_that("xwalk functions work", { + skip_if_not_installed("sf") + + block_xwalk <- make_block_xwalk( + state = "MD", + county = "Kent County" + ) + + expect_s3_class(block_xwalk, "sf") + + area_xwalk <- make_area_xwalk( + area = sf::st_buffer(xwalk[1,], dist = 5000), + block_xwalk = block_xwalk + ) + + expect_s3_class(area_xwalk, "tbl_df") + + acs_data <- get_acs_tables( + geography = "tract", + state = "MD", + county = "Kent County", + table = "B01003", + year = 2022 + ) + + acs_data_interp <- use_area_xwalk( + data = acs_data, + area_xwalk = area_xwalk + ) + + expect_snapshot( + acs_data_interp + ) +})