Mock for Session object, only some tests require this right now but more tests may require this session object in the future Right now only services need session$destroy() method to clear services so you can create same service in more then one test
with version 0.5.0 session mock can be used as the only object passed to root component constructor.
Public fields
token- string used by battery to distinguish users
input- shiny input
output- shiny output
Methods
Method new()
Session mock constructor
Usage
Session$new(
token = NULL,
input = battery::activeInput(),
output = battery::activeOutput()
)Examples
TestComponent <- battery::component(
"TestComponent",
public = list(
constructor = function() {
print(self$session$token)
}
)
)
session <- battery::Session$new("Test")
input <- activeInput()
output <- activeOutput()
component <- TestComponent$new(input = input, output = output, session = session)
#> [1] "Test"