Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Sep 3, 2024
1 parent 6ed049f commit 0b86f90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 3 additions & 6 deletions R/coda.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ coda_server <- function(id, x) {
stopifnot(is.reactive(x))

moduleServer(id, function(input, output, session) {
## Select groups -----
## Update UI -----
observe({
req(x())
index_numeric <- arkhe::detect(x = x(), f = is.numeric, margin = 2)
Expand All @@ -106,13 +106,11 @@ coda_server <- function(id, x) {
)
freezeReactiveValue(input, "groups")
updateSelectizeInput(
session,
inputId = "groups",
choices = c("", choices)
)
freezeReactiveValue(input, "condense")
updateSelectizeInput(
session,
inputId = "condense",
choices = c("", choices)
)
Expand All @@ -126,7 +124,7 @@ coda_server <- function(id, x) {
{
nexus::as_composition(
from = x(),
parts = input$parts,
parts = get_value(input$parts),
groups = get_value(input$groups),
verbose = get_option("verbose", default = FALSE)
)
Expand All @@ -135,10 +133,9 @@ coda_server <- function(id, x) {
)

if (isTruthy(input$condense)) {
by <- as.data.frame(x())[, input$condense]
by <- x()[, input$condense]
z <- nexus::condense(z, by = by)
}

z
})

Expand Down
2 changes: 1 addition & 1 deletion R/prepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ select_ui <- function(id) {
width = "100%"
)
}
select_server <- clean_server <- function(id, x) {
select_server <- function(id, x) {
stopifnot(is.reactive(x))

moduleServer(id, function(input, output, session) {
Expand Down
8 changes: 6 additions & 2 deletions inst/tinytest/test_coda.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ imp <- nexus::replace_zero(nexus::as_composition(fake, groups = 1),
x <- reactiveVal(fake)

testServer(coda_server, args = list(x = x), {
session$setInputs(groups = "", condense = "group")
expect_equal(NROW(coda()), 3)
session$setInputs() # Needed because of freezeReactiveValue() (???)
session$setInputs(parts = c(2, 3), groups = "", condense = "")
expect_equal(dim(coda()), c(9L, 2L))

session$setInputs(parts = c(2, 3, 4), condense = "group")
expect_equal(dim(coda()), c(3L, 3L))

session$setInputs(groups = "", condense = "", delta = 2/3,
limit_Ca = 0, limit_Fe = 0, limit_Na = 0)
Expand Down

0 comments on commit 0b86f90

Please sign in to comment.