Skip to content

Commit

Permalink
Do not flush when setting the returned value in a mocked shiny session
Browse files Browse the repository at this point in the history
This requires $flushReact() to be called when wanting to access reactive values that do not require inputs to be set
  • Loading branch information
schloerke committed Apr 21, 2020
1 parent 83e2bb0 commit 0241f07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions R/mock-session.R
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ MockShinySession <- R6Class(
#' @param value The value returned from the module
setReturned = function(value) {
self$returned <- value
private$flush()
value
},
#' @description Get the value returned by the module call.
Expand Down Expand Up @@ -461,4 +460,3 @@ MockShinySession <- R6Class(
}
)
)

3 changes: 3 additions & 0 deletions tests/testthat/test-test-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ test_that("testServer handles reactivePoll", {
}

testServer(module, {
session$flushReact()
expect_equal(rv$x, 1)

for (i in 1:4){
Expand All @@ -189,6 +190,7 @@ test_that("testServer handles reactiveTimer", {
}

testServer(module, {
session$flushReact()
expect_equal(rv$x, 1)

session$elapse(200)
Expand Down Expand Up @@ -593,6 +595,7 @@ test_that("testServer handles invalidateLater", {
}

testServer(module, {
session$flushReact()
# Should have run once
expect_equal(rv$x, 1)

Expand Down

0 comments on commit 0241f07

Please sign in to comment.