tests/testthat/test-ai_tool_read_currently_open_file.R

test_that("read_currently_open_file - no file open", {
  local_mocked_bindings(
    getSourceEditorContext = function(...) NULL,
    .package = "myownrobs"
  )
  expect_equal(
    read_currently_open_file(list()),
    list(filepath = "NO CURRENT FILE", content = "There are no files currently open.")
  )
})

test_that("read_currently_open_file - file open", {
  local_mocked_bindings(
    getSourceEditorContext = function(...) list(path = "", contents = "CONTENT"),
    .package = "myownrobs"
  )
  expect_equal(
    read_currently_open_file(list()),
    list(filepath = "ACTIVE_R_DOCUMENT", content = "CONTENT")
  )
})

Try the myownrobs package in your browser

Any scripts or data that you put into this service are public.

myownrobs documentation built on Nov. 5, 2025, 5:52 p.m.