Skip to content

Commit

Permalink
Test edge case of pressing button with no data selected
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft committed Oct 31, 2024
1 parent 3a47023 commit ca3cf83
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/testthat/test-mod_select_for_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ test_that("mod_select_for_export_server only reacts to button click", {
expect_type(out(), "character")
expect_length(out(), 0)

# Clicking the button without input should just do nothing
session$setInputs(add_to_export = 1)
session$flushReact()
expect_length(out(), 0)


# Update input data, the output should not be updated
n_selected <- 10
concepts_data(data.frame(concept_id = seq_len(n_selected)))
session$flushReact()
expect_length(out(), 0)

# Mimic button clicking, the output show now be updated
session$setInputs(add_to_export = 1)
session$setInputs(add_to_export = 2)
session$flushReact()
expect_length(out(), n_selected)
}
Expand Down

0 comments on commit ca3cf83

Please sign in to comment.