From cb2ae09b80f60d3e70a7faa8daf62bdc0158fa2c Mon Sep 17 00:00:00 2001 From: James McMahon Date: Tue, 23 Jul 2024 09:25:25 +0100 Subject: [PATCH] Add tests to use tidyselect --- tests/testthat/test-get_simd_postcode.R | 13 +++++++++++++ tests/testthat/test-get_spd.R | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/testthat/test-get_simd_postcode.R b/tests/testthat/test-get_simd_postcode.R index ba695d2..b628457 100644 --- a/tests/testthat/test-get_simd_postcode.R +++ b/tests/testthat/test-get_simd_postcode.R @@ -26,3 +26,16 @@ test_that("col selection works", { ) |> expect_message() }) + +test_that("col selection works with tidyselect", { + expect_named( + get_simd_postcode(col_select = c("pc7", dplyr::starts_with("simd"))) + ) |> + expect_message() + + expect_named( + get_simd_postcode(col_select = dplyr::matches("pc[78]")), + c("pc7", "pc8") + ) |> + expect_message() +}) diff --git a/tests/testthat/test-get_spd.R b/tests/testthat/test-get_spd.R index 1a2938f..ff67a7a 100644 --- a/tests/testthat/test-get_spd.R +++ b/tests/testthat/test-get_spd.R @@ -26,3 +26,16 @@ test_that("col selection works", { ) |> expect_message() }) + +test_that("col selection works with tidyselect", { + expect_named( + get_spd(col_select = c("pc7", dplyr::starts_with("hb"))) + ) |> + expect_message() + + expect_named( + get_spd(col_select = dplyr::matches("pc[78]")), + c("pc7", "pc8") + ) |> + expect_message() +})