Skip to content

Commit

Permalink
Update test-useconfetti.R
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurData authored Jul 8, 2022
1 parent 22736a6 commit 478f781
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/testthat/test-useconfetti.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
"<canvas style=\"position: fixed; top: 0px; left: 0px; pointer-events: none; z-index: 100;\" width=\"992\" height=\"1323\"></canvas>"
)
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)
})

0 comments on commit 478f781

Please sign in to comment.