library(shiny)
library(testthat)
example_server_fn <- function(input, output, session) {
observeEvent(input$trigger, {
updateTextInput(
inputId = "result",
label = "New Label",
value = NULL,
placeholder = "New placeholder"
)
})
}
test_that("Check that text input gets updated", {
use_shiny_testers()
shiny::testServer(
app = example_server_fn,
expr = {
session$setInputs(result = "Example text")
session$setInputs(trigger = 1L)
expect_identical(input$result, "Example text")
expect_identical(input$result.label, "New Label")
expect_identical(input$result.placeholder, "New placeholder")
}
)
})
Run the code above in your browser using DataLab