tests/testthat/test-widget.R

test_that("the widget carries the page and the options", {
    set.seed(8)
    f <- vol_field(array(runif(2 * 4 * 4, 1, 9), c(2L, 4L, 4L)),
                   lon = 1:4, lat = 1:4, depth = c(0, 10))
    p <- vol_payload(f, tempfile("pl"))
    w <- vol_widget(p, options = list(slab = TRUE, slabT = 5))
    expect_s3_class(w, "htmlwidget")
    expect_true(grepl("__VOLUME_MANIFEST__", w$x$html, fixed = TRUE))
    expect_true(w$x$options$slab)
    expect_true(w$x$options$panel)
})

test_that("the template the package ships is the page the build inlines into", {
    tpl <- vol_viewer_template()
    expect_true(file.exists(tpl))
    txt <- paste(readLines(tpl, warn = FALSE), collapse = "\n")
    expect_true(grepl("\"use strict\"", txt, fixed = TRUE))
    expect_false(grepl("data:image/png;base64,", txt, fixed = TRUE))
    expect_false(grepl("window.__VOLUME_MANIFEST__ = {", txt, fixed = TRUE))
})

Try the volumr package in your browser

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

volumr documentation built on Dec. 2, 2026, 5:07 p.m.