Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbythorpe committed Dec 14, 2024
1 parent eebbd2b commit 187d532
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/testthat/test-global_actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,52 @@ test_that("Global actions work", {

expect_s3_class(html, "xml_document")
})

test_that("Scrolling works", {
session <- selenider_test_session()

html <- "
<!DOCTYPE html>
<div style = 'height:110%; width:110%; min-height:110vh; min-width:110vh;'></div>
"

open_url(paste0("data:text/html,", URLencode(html)))

scroll_to(10, 20)

expect_equal(
execute_js_expr("return window.scrollY;"),
10
)

expect_equal(
execute_js_expr("return window.scrollX;"),
20
)

scroll_by(-5, -10)

Sys.sleep(0.1)

expect_equal(
execute_js_expr("return window.scrollY;"),
5
)

expect_equal(
execute_js_expr("return window.scrollX;"),
10
)

scroll_to(0, 0)

expect_equal(
execute_js_expr("return window.scrollY;"),
0
)

expect_equal(
execute_js_expr("return window.scrollX;"),
0
)
})

0 comments on commit 187d532

Please sign in to comment.