Testing number of specs returned

This commit is contained in:
Sharla Gelfand 2021-04-28 17:00:33 -04:00
Родитель 53622c48bb
Коммит 37f6ea4d36
1 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,27 @@
test_that("datamation_sanddance returns a frame for the data, one for each group, and two for a summarise step", {
library(palmerpenguins)
pipeline <- "penguins %>% group_by(species)"
specs <- datamation_sanddance(pipeline)
expect_named(specs, c("data", "group_by"))
expect_length(specs[["data"]], 1)
expect_length(specs[["group_by"]], 1)
pipeline <- "penguins %>% group_by(species, island)"
specs <- datamation_sanddance(pipeline)
expect_named(specs, c("data", "group_by"))
expect_length(specs[["data"]], 1)
expect_length(specs[["group_by"]], 2)
pipeline <- "penguins %>% group_by(species, island, sex)"
specs <- datamation_sanddance(pipeline)
expect_named(specs, c("data", "group_by"))
expect_length(specs[["data"]], 1)
expect_length(specs[["group_by"]], 3)
pipeline <- "penguins %>% group_by(species, island) %>% summarize(mean = mean(bill_length_mm))"
specs <- datamation_sanddance(pipeline)
expect_named(specs, c("data", "group_by"))
expect_length(specs[["data"]], 1)
expect_length(specs[["group_by"]], 3)
})