tests/testthat/test-file_Input.R

test_that("file input works", {
  file_check <- file_Input("inputId", "Test")

  expect_identical(
    file_check$children[[1]]$children[[1]],
    "Test"
  )
})

test_that("file input HTML is as expected", {
  local_edition(3)
  expect_snapshot(file_Input(
    "inputId",
    "Test",
    multiple = TRUE,
    accept = c(".xls")
  ))
})

test_that("file input error works", {
  file_check <- file_Input(
    "inputId",
    "Test",
    error = TRUE,
    error_message = "Error test"
  )

  expect_identical(
    file_check$children[[2]]$children[[1]],
    "Error test"
  )

  expect_identical(
    paste(
      file_check$children[[2]]$attribs$class,
      file_check$children[[2]]$attribs[3]$class
    ),
    "govuk-error-message shinyjs-hide"
  )
})

Try the shinyGovstyle package in your browser

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

shinyGovstyle documentation built on April 13, 2026, 5:06 p.m.