-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aedb9b8
commit e542a37
Showing
5 changed files
with
94 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# input validation works as expected | ||
|
||
"<input id=\"caption2\" value=\"1\" type=\"text\" class=\"input-with-value shiny-bound-input\" required=\"required\" validate=\"\" pattern=\"[0-9]*\" data-error-message=\"Only numbers please!\">" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
test_that("Input validation R function works", { | ||
session <- as.environment(list( | ||
ns = identity, | ||
sendCustomMessage = function(type, message) { | ||
session$lastCustomMessage <- list(type = type, message = message) | ||
} | ||
)) | ||
|
||
validateF7Input( | ||
inputId = "caption2", | ||
pattern = "[0-9]*", | ||
error = "Only numbers please!", | ||
session = session | ||
) | ||
|
||
res <- session$lastCustomMessage | ||
expect_length(res, 2) | ||
expect_equal(res$type, "validate-input") | ||
expect_length(res$message, length(formals(validateF7Input)) - 2) | ||
expect_equal(res$message$target, "caption2") | ||
}) | ||
|
||
library(shinytest2) | ||
test_that("input validation works as expected", { | ||
# Don't run these tests on the CRAN build servers | ||
skip_on_cran() | ||
shiny_app_path <- | ||
system.file("examples/validateinput/app.R", package = "shinyMobile") | ||
|
||
app <- AppDriver$new( | ||
shiny_app_path, | ||
name = "validateinput-app", | ||
variant = platform_variant() | ||
) | ||
|
||
app$wait_for_idle(1000) | ||
# Expect props to be present in HTML: there are no Shiny inputs/outputs related to tooltips | ||
app$expect_html(selector = "#caption2") | ||
|
||
}) |