tests/testthat/test_hide_trace_idx.R

test_that("correct idx are returned for JS idx notation", {
  tmap <- as.matrix(cbind(c(1:5), c(0:4)))

  # assume df with 5 groups,

  #### NOTE: previous - seems that group idx changed to start from 1
  #### group 2 selected would imply removing index "1" (JS starts at 0)

  #### CURRENT:
  # group 2 selected would imply removing index "2"
  out <- hide_trace_idx(tmap, 5, 2)

  # expect_identical(out, c(0,2,3,4))
  expect_identical(out, as.integer(c(0, 2, 3, 4)))
})



test_that("NULL returned for no group selection", {
  tmap <- as.matrix(cbind(c(1:5), c(0:4)))

  # assume df with 5 groups,
  out <- hide_trace_idx(tmap, 5, NULL)


  expect_null(out)
})


test_that("NULL returned when  all groups selected", {
  tmap <- as.matrix(cbind(c(1:5), c(0:4)))

  # assume df with 5 groups,
  out <- hide_trace_idx(tmap, 5, 1:5)


  expect_null(out)
})

Try the datacleanr package in your browser

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

datacleanr documentation built on June 8, 2025, 10:27 a.m.