Преглед изворни кода

fix requires_packages tests and mocking

tags/v0.3.0
Garrick Aden-Buie пре 6 година
родитељ
комит
ed365818d1
2 измењених фајлова са 7 додато и 14 уклоњено
  1. +6
    -12
      tests/testthat/test-ggplot2.R
  2. +1
    -2
      tests/testthat/test-utils.R

+ 6
- 12
tests/testthat/test-ggplot2.R Прегледај датотеку

@@ -468,22 +468,16 @@ describe("scale_xaringan_*", {
})

test_that("register_font() returns the name of the font family if font pkgs are missing", {
family_showtext_missing <- with_mock(
requires_package = function(pkg, ...) pkg != "showtext",
with_clean_session(function() {
xaringanthemer::style_xaringan(outfile = NULL)
xaringanthemer:::get_theme_font()
})
family_showtext_missing <- testthat::with_mock(
`xaringanthemer:::requires_package` = function(pkg, ...) pkg != "showtext",
register_font(formals(style_xaringan)$text_font_family, google = TRUE)
)

expect_equal(family_showtext_missing, formals(style_xaringan)$text_font_family)

family_sysfonts_missing <- with_mock(
requires_package = function(pkg, ...) pkg != "sysfonts",
with_clean_session(function() {
xaringanthemer::style_xaringan(outfile = NULL)
xaringanthemer:::get_theme_font()
})
family_sysfonts_missing <- testthat::with_mock(
`xaringanthemer:::requires_package` = function(pkg, ...) pkg != "sysfonts",
register_font(formals(style_xaringan)$text_font_family, google = TRUE)
)
expect_equal(family_sysfonts_missing, formals(style_xaringan)$text_font_family)
})

+ 1
- 2
tests/testthat/test-utils.R Прегледај датотеку

@@ -8,6 +8,5 @@ test_that("printing google_font works", {
test_that("requires_package()", {
expect_true(requires_package("purrr"))
expect_error(requires_package("notapackage", "myFunction"), "myFunction")
expect_warning(requires_package("notapackage", required = FALSE))
expect_false(requires_package("notapackage", required = FALSE))
expect_warning(expect_false(requires_package("notapackage", required = FALSE)))
})

Loading…
Откажи
Сачувај