tests/testthat/test_utility-watermark.R

context("Create a watermark")

test_that("A file with a watermark is successfully created", {
			
  file <- tempfile(pattern = "watermark", fileext = ".png")
  getWatermark(file = file)
  expect_true(file.exists(file))
	
})

test_that("A watermark is successfully added to a plotly object", {
			
  file <- tempfile(pattern = "watermark", fileext = ".png")
  getWatermark(file = file)
  pl <- plotly::plot_ly(type = "scatter", mode = "marker")
  pl <- addWatermark(pl = pl, watermark = file)
  
  # check that an image has been included below the plot
  plBuild <- plotly::plotly_build(pl)
  expect_equal(
    object = sapply(plBuild$x$layout$images, `[[`, "layer"),
    expected = "below"
  )
			
})

Try the clinDataReview package in your browser

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

clinDataReview documentation built on April 12, 2025, 1:14 a.m.