tests/testthat/test_websockets.R

#' @include Websockets.R
#' @include internal.R

library(websocket)

vcr::vcr_configure(dir = file.path(dirname(.log_path), "websockets"))
if (rlang::is_interactive()) {

  test_that("ws_create returns the appropriate websocket object", {
    .ws <- ws_create("Alpaca", log_msgs = F)
    expect_identical(class(.ws$ws), c("WebSocket", "R6"))
    expect_identical(attr(.ws, "api"), "a")
    .rs <- .ws$ws$readyState()[1]
    expect_equal(.rs, 0)
    .ws$ws$close()
    .ws <- ws_create("Polygon", log_msgs = F)
    expect_identical(class(.ws$ws), c("WebSocket", "R6"))
    expect_identical(attr(.ws, "api"), "p")
    expect_equal(.ws$ws$readyState()[1], 0)
    .ws$ws$close()
})
  
}
jagg19/AlpacaforR documentation built on July 3, 2023, 12:14 p.m.