tests/testthat/test-creation.R

test_that( "sortable_js makes a htmlwidget ", {
  expect_s3_class( sortable_js( "" ), "htmlwidget" )
  expect_s3_class( sortable_js( "" ), "sortable" )
})

test_that( "sortable_js height and width", {
  # by default sortable_js should be 0 height and width
  #  since intended to be used to provide dependencies
  #  and pass config options
  expect_equal( sortable_js( "" )$width, 0 )
  expect_equal( sortable_js( "" )$height, 0 )
  # however, someone might want to override height/width
  expect_equal( sortable_js( "", width = 100 )$width, 100 )
  expect_equal( sortable_js( "", height = 100 )$height, 100 )
})

test_that( "css_id and options passed as expected", {
  expect_identical( sortable_js( "an_id" )$x$css_id, "an_id" )
  expect_identical(
    sortable_js(
      "an_id",
      options = sortable_options(
        group = "name",
        sort = FALSE,
        disabled = FALSE
      )
    )$x,
    list(
      css_id = "an_id",
      options = modifyList(
        default_sortable_options(),
        sortable_options(
          group = "name",
          sort = FALSE,
          disabled = FALSE
        )
      )
    )
  )
})

Try the sortable package in your browser

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

sortable documentation built on March 31, 2023, 9:35 p.m.