Package with an initial set of functions added

NOTE: Not all tests have been written yet!
This commit is contained in:
2026-01-22 15:59:54 +00:00
parent c94ca1549a
commit 6d3843a92b
25 changed files with 711 additions and 4 deletions

View File

@@ -0,0 +1,47 @@
test_that("maximum length password input", {
x <- shiny::passwordInput("input_id", "Some password input")
y <- "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some password input</label>\n <input id=\"input_id\" type=\"password\" class=\"shiny-input-password form-control\" value=\"\" data-update-on=\"change\" maxlength=\"50\"/>\n</div>"
expect_equal(as.character(htmlSetMaxLength(x, 50)), y)
})
test_that("minimum length password input", {
x <- shiny::passwordInput("input_id", "Some password input")
y <- "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some password input</label>\n <input id=\"input_id\" type=\"password\" class=\"shiny-input-password form-control\" value=\"\" data-update-on=\"change\" minlength=\"3\"/>\n</div>"
expect_equal(as.character(htmlSetMinLength(x, 3)), y)
})
test_that("min/max length password input", {
x <- shiny::passwordInput("input_id", "Some password input")
y <- "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some password input</label>\n <input id=\"input_id\" type=\"password\" class=\"shiny-input-password form-control\" value=\"\" data-update-on=\"change\" minlength=\"3\" maxlength=\"50\"/>\n</div>"
expect_equal(as.character(htmlSetMaxLength(htmlSetMinLength(x, 3), 50)), y)
})
test_that("maximum length text input", {
x <- shiny::textInput("input_id", "Some text input")
y <- "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some text input</label>\n <input id=\"input_id\" type=\"text\" class=\"shiny-input-text form-control\" value=\"\" data-update-on=\"change\" maxlength=\"50\"/>\n</div>"
expect_equal(as.character(htmlSetMaxLength(x, 50)), y)
})
test_that("minimum length text input", {
x <- shiny::textInput("input_id", "Some text input")
y <- "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some text input</label>\n <input id=\"input_id\" type=\"text\" class=\"shiny-input-text form-control\" value=\"\" data-update-on=\"change\" minlength=\"3\"/>\n</div>"
expect_equal(as.character(htmlSetMinLength(x, 3)), y)
})
test_that("min/max length text input", {
x <- shiny::textInput("input_id", "Some text input")
y <- "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some text input</label>\n <input id=\"input_id\" type=\"text\" class=\"shiny-input-text form-control\" value=\"\" data-update-on=\"change\" minlength=\"3\" maxlength=\"50\"/>\n</div>"
expect_equal(as.character(htmlSetMaxLength(htmlSetMinLength(x, 3), 50)), y)
})
test_that("maximum length textarea input", {
x <- shiny::textAreaInput("input_id", "Some textarea input")
y <- "<div class=\"shiny-input-textarea form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some textarea input</label>\n <textarea id=\"input_id\" class=\"form-control\" data-update-on=\"change\" maxlength=\"500\"></textarea>\n</div>"
expect_equal(as.character(htmlSetMaxLength(x, 500)), y)
})
test_that("minimum length textarea input", {
x <- shiny::textAreaInput("input_id", "Some textarea input")
y <- "<div class=\"shiny-input-textarea form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some textarea input</label>\n <textarea id=\"input_id\" class=\"form-control\" data-update-on=\"change\" minlength=\"50\"></textarea>\n</div>"
expect_equal(as.character(htmlSetMinLength(x, 50)), y)
})
test_that("min/max length textarea input", {
x <- shiny::textAreaInput("input_id", "Some textarea input")
y <- "<div class=\"shiny-input-textarea form-group shiny-input-container\">\n <label class=\"control-label\" id=\"input_id-label\" for=\"input_id\">Some textarea input</label>\n <textarea id=\"input_id\" class=\"form-control\" data-update-on=\"change\" minlength=\"50\" maxlength=\"500\"></textarea>\n</div>"
expect_equal(as.character(htmlSetMaxLength(htmlSetMinLength(x, 50), 500)), y)
})