tests/test_mod_data_load.r

#test_module_upload

# Given the following module
computation_module_server <- function(input, output, session){
  ns <- session$ns
  r <- reactiveValues(
    value = NULL
  )
  observeEvent( input$selector , {
    r$value <- input$selector * 10
  })

}

# We can test it that way
library(shiny)
library(testthat)
testModule(computation_module_server, {

  # Give input$selector a value
  session$setInputs(selector = 1)
  # Call {testthat} functions
  expect_equal(r$value, 10)

  # Give input$selector a value
  session$setInputs(selector = 2)
  # Call {testthat} functions
  expect_equal(r$value, 20)


})
jas1/pathEventDataExplorer documentation built on Jan. 23, 2021, 12:47 a.m.