Skip to content

Commit

Permalink
add unit test for new funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
parmsam committed Jul 9, 2024
1 parent f499d22 commit dd63903
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/testthat/test-list.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test_that("Listing extensions", {
skip_if_no_quarto()
skip_if_offline("github.com")
qmd <- local_qmd_file(c("content"))
withr::local_dir(dirname(qmd))
expect_null(quarto_list_extensions())
quarto_add_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
expect_true(dir.exists("_extensions/quarto-ext/fontawesome"))
expect_equal(nrow(quarto_list_extensions()), 1)
quarto_add_extension("quarto-ext/lightbox", no_prompt = TRUE, quiet = TRUE)
expect_true(dir.exists("_extensions/quarto-ext/lightbox"))
expect_equal(nrow(quarto_list_extensions()), 2)
})
11 changes: 11 additions & 0 deletions tests/testthat/test-remove.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("Removing an extension", {
skip_if_no_quarto()
skip_if_offline("github.com")
qmd <- local_qmd_file(c("content"))
withr::local_dir(dirname(qmd))
expect_null(quarto_remove_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE))
quarto_add_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
expect_true(dir.exists("_extensions/quarto-ext/fontawesome"))
quarto_remove_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
expect_true(!dir.exists("_extensions/quarto-ext/fontawesome"))
})
11 changes: 11 additions & 0 deletions tests/testthat/test-update.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("Updating an extension", {
skip_if_no_quarto()
skip_if_offline("github.com")
qmd <- local_qmd_file(c("content"))
withr::local_dir(dirname(qmd))
expect_error(quarto_add_extension("quarto-ext/[email protected]"), "explicit approval")
quarto_update_extension("quarto-ext/fontawesome", no_prompt = TRUE, quiet = TRUE)
expect_true(dir.exists("_extensions/quarto-ext/fontawesome"))
current_version <- yaml::read_yaml("_extensions/quarto-ext/fontawesome/_extension.yml")$version
expect_false(identical(current_version, "v0.0.1"))
})

0 comments on commit dd63903

Please sign in to comment.