j+3+yu$mZY0%mUB{VXPe^G<+&E)_2wl`94IeA*Qy$Eyj4+xXP3IL
z%wp^#n@XzDcmAH2_?c7AYu0O2RQJ_+X{Lu8as+J3%|w2hX_R!$v=<=x@hta~>t`a%
zed(L^QL4YvnHY0``u32`qz$kd7k;Pz$8fWG0H@;zp!ngysN#DA!-_`+ZYmTN>lBI~
W%_N?g*f7>j!engbU@no9xc>v_w5JCE
diff --git a/man/run_app.Rd b/man/run_app.Rd
index 6be75ea..c6c36f7 100644
--- a/man/run_app.Rd
+++ b/man/run_app.Rd
@@ -33,7 +33,7 @@ request to determine whether the \code{ui} should be used to handle the
request. Note that the entire request path must match the regular
expression in order for the match to be considered successful.}
-\item{...}{arguments to pass to golem_opts.
+\item{...}{arguments to pass to golem_opts.
See `?golem::get_golem_options` for more details.}
}
\description{
diff --git a/tests/spelling.R b/tests/spelling.R
new file mode 100644
index 0000000..6713838
--- /dev/null
+++ b/tests/spelling.R
@@ -0,0 +1,3 @@
+if(requireNamespace('spelling', quietly = TRUE))
+ spelling::spell_check_test(vignettes = TRUE, error = FALSE,
+ skip_on_cran = TRUE)
diff --git a/tests/testthat.R b/tests/testthat.R
new file mode 100644
index 0000000..531684a
--- /dev/null
+++ b/tests/testthat.R
@@ -0,0 +1,12 @@
+# This file is part of the standard setup for testthat.
+# It is recommended that you do not modify it.
+#
+# Where should you do additional test configuration?
+# Learn more about the roles of various files in:
+# * https://r-pkgs.org/tests.html
+# * https://testthat.r-lib.org/reference/test_package.html#special-files
+
+library(testthat)
+library(chatgptimages)
+
+test_check("chatgptimages")
diff --git a/tests/testthat/test-golem-recommended.R b/tests/testthat/test-golem-recommended.R
new file mode 100644
index 0000000..b314130
--- /dev/null
+++ b/tests/testthat/test-golem-recommended.R
@@ -0,0 +1,74 @@
+test_that("app ui", {
+ ui <- app_ui()
+ golem::expect_shinytaglist(ui)
+ # Check that formals have not been removed
+ fmls <- formals(app_ui)
+ for (i in c("request")) {
+ expect_true(i %in% names(fmls))
+ }
+})
+
+test_that("app server", {
+ server <- app_server
+ expect_type(server, "closure")
+ # Check that formals have not been removed
+ fmls <- formals(app_server)
+ for (i in c("input", "output", "session")) {
+ expect_true(i %in% names(fmls))
+ }
+})
+
+test_that(
+ "app_sys works",
+ {
+ expect_true(
+ app_sys("golem-config.yml") != ""
+ )
+ }
+)
+
+test_that(
+ "golem-config works",
+ {
+ config_file <- app_sys("golem-config.yml")
+ skip_if(config_file == "")
+
+ expect_true(
+ get_golem_config(
+ "app_prod",
+ config = "production",
+ file = config_file
+ )
+ )
+ expect_false(
+ get_golem_config(
+ "app_prod",
+ config = "dev",
+ file = config_file
+ )
+ )
+ }
+)
+
+# Configure this test to fit your need.
+# testServer() function makes it possible to test code in server functions and modules, without needing to run the full Shiny application
+testServer(app_server, {
+
+ # Set and test an input
+ session$setInputs(x = 2)
+ expect_equal(input$x, 2)
+
+ # Example of tests you can do on the server:
+ # - Checking reactiveValues
+ # expect_equal(r$lg, 'EN')
+ # - Checking output
+ # expect_equal(output$txt, "Text")
+})
+
+# Configure this test to fit your need
+test_that(
+ "app launches",
+ {
+ golem::expect_running(sleep = 5)
+ }
+)
diff --git a/tests/testthat/test-golem_utils_server.R b/tests/testthat/test-golem_utils_server.R
new file mode 100644
index 0000000..770d387
--- /dev/null
+++ b/tests/testthat/test-golem_utils_server.R
@@ -0,0 +1,54 @@
+test_that("not_in works", {
+ expect_true(1 %not_in% 2:10)
+ expect_false(1 %not_in% 1:10)
+})
+
+test_that("not_null works", {
+ expect_true(not_null(1))
+ expect_false(not_null(NULL))
+})
+
+test_that("not_na works", {
+ expect_true(not_na(1))
+ expect_false(not_na(NA))
+})
+
+test_that("drop_nulls works", {
+ expect_equal(
+ drop_nulls(
+ list(x = NULL, y = 2)
+ ),
+ list(y = 2)
+ )
+})
+
+test_that("%||% works", {
+ expect_equal(
+ NULL %||% 1,
+ 1
+ )
+ expect_equal(
+ 2 %||% 1,
+ 2
+ )
+})
+
+test_that("%|NA|% works", {
+ expect_equal(
+ NA %|NA|% 1,
+ 1
+ )
+ expect_equal(
+ 2 %|NA|% 1,
+ 2
+ )
+})
+
+test_that("rv and rvtl work", {
+ expect_true(
+ inherits(rv, "function")
+ )
+ expect_true(
+ inherits(rvtl, "function")
+ )
+})
diff --git a/tests/testthat/test-golem_utils_ui.R b/tests/testthat/test-golem_utils_ui.R
new file mode 100644
index 0000000..a33935c
--- /dev/null
+++ b/tests/testthat/test-golem_utils_ui.R
@@ -0,0 +1,177 @@
+test_that("Test with_red_star works", {
+ expect_s3_class(with_red_star("golem"), "shiny.tag")
+ expect_equal(
+ as.character(with_red_star("Enter your name here")),
+ 'Enter your name here* '
+ )
+})
+
+test_that("Test list_to_li works", {
+ expect_s3_class(list_to_li(c("a", "b")), "shiny.tag.list")
+ expect_equal(
+ as.character(list_to_li(c("a", "b"))),
+ "a \nb "
+ )
+ expect_equal(
+ as.character(list_to_li(c("a", "b"), class = "my_li")),
+ 'a \nb '
+ )
+})
+
+test_that("Test list_to_p works", {
+ expect_s3_class(
+ list_to_p(c(
+ "This is the first paragraph",
+ "this is the second paragraph"
+ )),
+ "shiny.tag.list"
+ )
+ expect_equal(
+ as.character(
+ list_to_p(c(
+ "This is the first paragraph",
+ "this is the second paragraph"
+ ))
+ ),
+ "This is the first paragraph
\nthis is the second paragraph
"
+ )
+ expect_equal(
+ as.character(
+ list_to_p(
+ c(
+ "This is the first paragraph",
+ "this is the second paragraph"
+ ),
+ class = "my_li"
+ )
+ ),
+ 'This is the first paragraph
\nthis is the second paragraph
'
+ )
+})
+
+test_that("Test named_to_li works", {
+ expect_s3_class(named_to_li(list(a = "a", b = "b")), "shiny.tag.list")
+ expect_equal(
+ as.character(named_to_li(list(a = "a", b = "b"))),
+ "a: a \nb: b "
+ )
+ expect_equal(
+ as.character(named_to_li(list(a = "a", b = "b"), class = "mylist")),
+ 'a: a \nb: b '
+ )
+})
+
+test_that("Test tagRemoveAttributes works", {
+ a_with_tag <- shiny::tags$p(src = "plop", "pouet")
+ expect_s3_class(a_with_tag, "shiny.tag")
+ expect_equal(
+ as.character(a_with_tag),
+ 'pouet
'
+ )
+
+ a_without_tag <- tagRemoveAttributes(a_with_tag, "src")
+ expect_s3_class(a_without_tag, "shiny.tag")
+ expect_equal(
+ as.character(a_without_tag),
+ "pouet
"
+ )
+})
+
+test_that("Test undisplay works", {
+ a <- shiny::tags$p(src = "plop", "pouet")
+ expect_s3_class(a, "shiny.tag")
+ expect_equal(
+ as.character(a),
+ 'pouet
'
+ )
+ a_undisplay <- undisplay(a)
+ expect_s3_class(a_undisplay, "shiny.tag")
+ expect_equal(
+ as.character(a_undisplay),
+ 'pouet
'
+ )
+
+ b <- shiny::actionButton("go_filter", "go")
+ expect_s3_class(b, "shiny.tag")
+ expect_equal(
+ as.character(b),
+ 'go '
+ )
+ b_undisplay <- undisplay(b)
+ expect_s3_class(b, "shiny.tag")
+ expect_equal(
+ as.character(b_undisplay),
+ 'go '
+ )
+})
+
+test_that("Test display works", {
+ a_undisplay <- shiny::tags$p(src = "plop", "pouet", style = "display: none;")
+ expect_s3_class(a_undisplay, "shiny.tag")
+ expect_equal(
+ as.character(a_undisplay),
+ 'pouet
'
+ )
+ a_display <- display(a_undisplay)
+ expect_s3_class(a_display, "shiny.tag")
+ expect_equal(
+ as.character(a_display),
+ 'pouet
'
+ )
+})
+
+test_that("Test jq_hide works", {
+ expect_s3_class(jq_hide("golem"), "shiny.tag")
+ expect_equal(
+ as.character(jq_hide("golem")),
+ ""
+ )
+})
+
+test_that("Test rep_br works", {
+ expect_s3_class(rep_br(5), "html")
+ expect_equal(
+ as.character(rep_br(5)),
+ " "
+ )
+})
+
+test_that("Test enurl works", {
+ expect_s3_class(enurl("https://www.thinkr.fr", "ThinkR"), "shiny.tag")
+ expect_equal(
+ as.character(enurl("https://www.thinkr.fr", "ThinkR")),
+ 'ThinkR '
+ )
+})
+
+test_that("Test columns wrappers works", {
+ expect_s3_class(col_12(), "shiny.tag")
+ expect_s3_class(col_10(), "shiny.tag")
+ expect_s3_class(col_8(), "shiny.tag")
+ expect_s3_class(col_6(), "shiny.tag")
+ expect_s3_class(col_4(), "shiny.tag")
+ expect_s3_class(col_3(), "shiny.tag")
+ expect_s3_class(col_2(), "shiny.tag")
+ expect_s3_class(col_1(), "shiny.tag")
+
+ expect_equal(as.character(col_12()), '
')
+ expect_equal(as.character(col_10()), '
')
+ expect_equal(as.character(col_8()), '
')
+ expect_equal(as.character(col_6()), '
')
+ expect_equal(as.character(col_4()), '
')
+ expect_equal(as.character(col_3()), '
')
+ expect_equal(as.character(col_2()), '
')
+ expect_equal(as.character(col_1()), '
')
+})
+
+test_that("Test make_action_button works", {
+ button <- make_action_button(
+ a(href = "#", "My super link", style = "color: lightblue;"),
+ inputId = "mylink"
+ )
+ expect_s3_class(button, "shiny.tag")
+ expect_equal(
+ as.character(button),
+ 'My super link '
+ )
+})