tests/testthat/test-app.R

test_that("the application opens on the tab it is asked for", {
    # Regression: the `tab` argument was accepted and never used.
    skip_if_not_installed("shiny")
    skip_if_not_installed("shinydashboard")
    html <- as.character(volumr_ui("volume"))
    sel <- regmatches(html, regexpr("<a href=\"#shiny-tab-[a-z]+\"[^>]*data-start-selected=\"1\"", html))
    expect_length(sel, 1L)
    expect_match(sel, "shiny-tab-volume", fixed = TRUE)
    expect_error(shinyVolumr(tab = "nowhere"), "should be one of")
})

test_that("an uploaded csv is read as a field", {
    d <- expand.grid(lon = 1:4, lat = 1:3, depth = c(0, 10))
    d$value <- seq_len(nrow(d))
    f <- tempfile(fileext = ".csv")
    utils::write.csv(d, f, row.names = FALSE)
    g <- suppressMessages(read_uploaded(list(name = "field.csv", datapath = f)))
    expect_s3_class(g, "vol_field")
    expect_identical(dim(g$values), c(2L, 3L, 4L))
})

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.