Skip to content
Permalink
Browse files

Corection get_dependencies and the end of tests

  • Loading branch information...
Cervangirard committed Jun 19, 2019
1 parent 9a29bbc commit c2845390e7f043dc2245e97e47bc9115f2603c46
@@ -2,7 +2,7 @@
#'
#' @param path path to the DESCRIPTION file
#' @param dput if TRUE return a dput output instead of character vector
#' @param field DESCRIPTION fields to parse. Default is Import and Depends
#' @param field DESCRIPTION fields to parse. Default is Import
#'
#' @export
#'
@@ -11,7 +11,7 @@
#' get_dependencies()
#' }
#' @importFrom stats setNames
get_dependencies <- function(path="DESCRIPTION",dput=FALSE,field=c('Depends','Imports')){
get_dependencies <- function(path="DESCRIPTION",dput=FALSE,field=c('Imports')){
out <- read.dcf(path)[,field]
out <- gsub(pattern = "\n",replacement = "", out)
out <- unlist(strsplit(out, ","))
@@ -23,6 +23,9 @@ usethis::use_test("favicon")
usethis::use_test("use_utils")
usethis::use_test("expect_function")
usethis::use_test("reload")
usethis::use_test("js")
usethis::use_test("aaadependencies")
usethis::use_test("create_golem")

# Travis
usethis::use_travis()

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,10 @@
context("tests get_dependencies")

test_that("test get_dependencies",{
with_dir(pkg,{
test <- get_dependencies()
expect_equal(test, c("shiny","golem"))
test2 <- capture_output(get_dependencies(dput = TRUE))
expect_equal(test2,"c(\"shiny\", \"golem\")")
})
})
@@ -0,0 +1,9 @@
context("tests create_golem")



test_that("test create_golem",{

expect_error(create_golem(file.path(tpdir, "pkgtest"), open = FALSE))

})
@@ -36,4 +36,21 @@ test_that("test print_dev",{
expect_equal(print_dev("test"),"test")
expect_is(print_dev("test"), "character")
})
})
})


test_that("test browser_button",{

output <- capture_output(browser_button())
normal_text <- readRDS("txt_browser_button.rds")
expect_equal(output,normal_text)
})

test_that("test set_option",{
with_dir(pkg,{
set_golem_options()
expect_equal(getOption("golem.pkg.name"), "pkgtest")
# expect_equal(getOption("golem.pkg.version"), "0.0.0.9000")
expect_equal(getOption("golem.app.prod"), FALSE)
})
})
@@ -13,3 +13,13 @@ test_that("test expect_shinytaglist",{
expect_error(expect_shinytaglist('test'))
})
})

test_that("test expect_shinytaglist",{
with_dir(pkg,{

ui <- shiny::h1("Jean")
htmltools::save_html(ui,file = "jean.html")
expect_equal(capture_output(expect_html_equal(ui = ui,html = "jean.html")),"")

})
})
@@ -0,0 +1,11 @@
context("test js function")


test_that("active_js", {
expect_is(activate_js(),'shiny.tag')
})


test_that("invoke_js", {
expect_error(invoke_js())
})
@@ -1,9 +1,22 @@
context("tests reload")



test_that("test document_and_reload",{
with_dir(pkg,{
file.create("R/sum.R")
cat(
"#' @export
sum_golem <- function(a,b){a + b}",file ="R/sum.R")
document_and_reload()
expect_equal(sum_golem(1,2),3)
})
})

test_that("test detach_all_attached",{
env <- environment()
test <- eval(golem::detach_all_attached(),envir = env)
with_dir(pkg,{
test <- detach_all_attached()
ok <- all(purrr::map_lgl(test,~ is.null(.x)))
expect_true(test)

testthat::expect_true(ok)
})
})
Binary file not shown.

0 comments on commit c284539

Please sign in to comment.
You can’t perform that action at this time.