tests/testthat/test_reportingFormats.R

context("Test reporting formats")

test_that("A gitbook clinical data review format is correctly created", {
      
	# fix for: 'Using anchor_sections requires Pandoc 2.0+'
	skip_if_not(
		condition = rmarkdown::pandoc_available(version = "2.0"), 
		message = "pandoc 2.0 is not available"
	)	
			
	output <- gitbook_clinDataReview_report()
	expect_s3_class(output, "rmarkdown_output_format")
      
	output <- gitbook_clinDataReview_report(split_by = 'section')
	expect_s3_class(output, "rmarkdown_output_format")
	unlink("gitbook.css")
      
})

test_that("An HTML clinical data review format is correctly created", {
			
	# fix for: 'Using anchor_sections requires Pandoc 2.0+'
	skip_if_not(
		condition = rmarkdown::pandoc_available(version = "2.0"), 
		message = "pandoc 2.0 is not available"
	)
      
	res <- html_clinDataReview_report()
	expect_s3_class(res, "rmarkdown_output_format")
	expect_identical(
		object = res$pandoc$to,
		expected = "html"
	)
      
})

test_that("The reference to a logo is correctly created", {
    
	# create an example logo
	data(iris)
	vars <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")	
	pathPlotBasic <- tempfile(pattern = "scatterplotIris-basic", fileext = ".png")
	png(pathPlotBasic)
	pairs(iris[, vars])
	tmp <- dev.off()
			
	expect_silent(
		res <- clinDataReview:::addLogoGitbook(
			logo = pathPlotBasic
		)
	)
	expect_type(res, "list")
	expect_named(res, "in_header")
	expect_type(res$in_header, "character")
      
})

test_that("A logo is correctly added to a gitbook clinical data review report", {
		
	# fix for: 'Using anchor_sections requires Pandoc 2.0+'
	skip_if_not(
		condition = rmarkdown::pandoc_available(version = "2.0"), 
		message = "pandoc 2.0 is not available"
	)			
			
	# create an example logo
	data(iris)
	vars <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")	
	pathPlotBasic <- tempfile(pattern = "scatterplotIris-basic", fileext = ".png")
	png(pathPlotBasic)
	pairs(iris[, vars])
	tmp <- dev.off()
      
	expect_silent(
 		res <- gitbook_clinDataReview_report(logo = pathPlotBasic)
	)
	expect_s3_class(res, "rmarkdown_output_format")
	unlink("gitbook.css")
      
})

Try the clinDataReview package in your browser

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

clinDataReview documentation built on March 7, 2023, 5:13 p.m.