tests/test-ci/test-spanner-js.R

# Column spanners: colspan rendering, column reordering to body order.

assert("column spanner renders colspan", {
  html = build(list(
    data = list(a = 1, b = 2, c = 3),
    spanners = list(list(label = "AB", columns = list("a", "b")))
  ))
  (has_match(html, 'colspan="2".*>AB</th>'))
})

assert("spanner columns are reordered to body order before rendering", {
  # columns listed out of order (b before a) still render one spanner
  html = build(list(
    data = list(a = 1, b = 2, c = 3),
    spanners = list(list(label = "AB", columns = list("b", "a")))
  ))
  (has_match(html, 'colspan="2".*>AB</th>'))

  # after a move, spanner with columns in original (pre-move) order must
  # anchor to moved first column, not be dropped
  html = build(list(
    data = list(x = 1, a = 2, b = 3),
    ops = list(list(type = "move", columns = list("b", "a"), after = "x")),
    # body order becomes x, b, a; list spanner cols in pre-move order
    spanners = list(list(label = "AB", columns = list("a", "b")))
  ))
  (has_match(html, 'colspan="2".*>AB</th>'))
})

Try the lt package in your browser

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

lt documentation built on Oct. 17, 2026, 9:06 a.m.