From 9bb6e84dd68502406646bbd324b147b5e71f3da8 Mon Sep 17 00:00:00 2001 From: friessn Date: Tue, 24 Sep 2024 00:15:56 +0200 Subject: [PATCH] add tests --- tests/testthat/test-editor.R | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-editor.R b/tests/testthat/test-editor.R index ca16c20..2021715 100644 --- a/tests/testthat/test-editor.R +++ b/tests/testthat/test-editor.R @@ -16,7 +16,7 @@ test_that("set editor input", { editor = "input", editorParams = list( search = TRUE, - mask = "AAA-999", + mask = "", selectContents = TRUE, elementAttributes = list( maxlength = 10 @@ -27,3 +27,36 @@ test_that("set editor input", { expect_s3_class(t, "rtabulator") expect_s3_class(t, "htmlwidget") }) + +test_that("set editor area input", { + # Prepare + col = "input_var" + df <- data.frame(input_var = c("a","b","c")) + + + # Act + t <- tabulator(df) |> + set_column_editor_text_area(col) + + # Assert + expected_column_def <- list( + title = "input_var", + field = "input_var", + hozAlign = "left", + editor = "textarea", + editorParams = list( + elementAttributes = list( + maxlength = 10 + ), + mask = "", + selectContents = TRUE, + verticalNavigation = "editor", + shiftEnterSubmit = TRUE + ) + ) + expect_mapequal(t$x$options$columns[[1]], expected_column_def) + expect_s3_class(t, "rtabulator") + expect_s3_class(t, "htmlwidget") +}) + +