Skip to content

Commit

Permalink
write tests for [.teal_data
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr committed Oct 29, 2024
1 parent e53afc8 commit 1ea9d8f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/testthat/test-extract.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
testthat::test_that("`[.` returns empty teal_data for improper names", {
data <- teal_data(x = 1, a = 2)
testthat::expect_equal(data["y"], teal_data())
})

testthat::test_that("`[.` returns limited join_keys", {
data <- teal_data(a = 1, b = 2)

join_keys(data) <- join_keys(join_key("a", "b", "x"))
empty_join_keys <- join_keys()
attr(empty_join_keys, "names") <- character(0)
testthat::expect_equal(
join_keys(data["a"]), # By default named list || names() is character(0)
empty_join_keys # By default unnamed list || names() is NULL
)
})

0 comments on commit 1ea9d8f

Please sign in to comment.