From 478f781cc0b82b2951a9832f0c507a4c5654e9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Br=C3=A9ant?= <35060481+ArthurData@users.noreply.github.com> Date: Fri, 8 Jul 2022 16:30:29 +0200 Subject: [PATCH] Update test-useconfetti.R --- tests/testthat/test-useconfetti.R | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/testthat/test-useconfetti.R b/tests/testthat/test-useconfetti.R index 3e8c181..73af265 100644 --- a/tests/testthat/test-useconfetti.R +++ b/tests/testthat/test-useconfetti.R @@ -7,3 +7,28 @@ test_that("useConfetti works", { expect_equal(dep[["name"]], "canvas-confetti") expect_true(length(dep[["script"]]) > 1) }) + +test_that("sendConfetti works", { + library(shinytest2) + + expect_true(inherits(sendConfetti, "function")) + + app <- shinytest2::AppDriver$new( + system.file("shiny", "test", "app.R", package = "confetti") + ) + expect_equal(app$get_value(input = "go")[[1]], 0) + expect_equal(app$get_value(input = "sentConfetti")[[1]], 0) + + app$click("go") + html <- app$get_html("canvas") + expect_equal( + html, + "" + ) + expect_equal(app$get_value(input = "go")[[1]], 1) + expect_equal(app$get_value(input = "sentConfetti")[[1]], 1) + + app$click("go") + expect_equal(app$get_value(input = "go")[[1]], 2) + expect_equal(app$get_value(input = "sentConfetti")[[1]], 2) +})