test_that("first header is wrapped in page-header div", { html <- xml2::read_html('

First

Second

') tweak_homepage_html(html) expect_equal(xpath_attr(html, ".//div", "class"), "page-header") }) test_that("removes dummy page-header", { html <- xml2::read_html('

Header

') tweak_homepage_html(html) expect_equal(xpath_text(html, ".//h1"), "Header") }) test_that("can remove first header", { html <- xml2::read_html('

First

Second

') tweak_homepage_html(html, strip_header = TRUE) expect_equal(xpath_length(html, ".//div"), 0) }) test_that("can remove logo", { # Without link html <- xml2::read_html('

First

') tweak_homepage_html(html, bs_version = 5, logo = "mylogo.png") expect_snapshot(xpath_xml(html, ".//div")) # With link html <- xml2::read_html('

First

') tweak_homepage_html(html, bs_version = 5, logo = "mylogo.png") expect_snapshot(xpath_xml(html, ".//div")) }) # badges ------------------------------------------------------------------- test_that("can move badges to sidebar", { html <- xml2::read_html('

Title

') tweak_sidebar_html(html) expect_snapshot(xpath_xml(html, ".//div")) }) test_that("remove badges even if no dev-status div", { html <- xml2::read_html('

Title

') tweak_sidebar_html(html) expect_snapshot(html) }) test_that("remove dev-status & badges if badges suppress", { html <- xml2::read_html('

Title

') tweak_sidebar_html(html, show_badges = FALSE) expect_equal(xpath_length(html, "//div"), 0) }) test_that("doesn't find badges when they don't exist", { expect_equal(badges_extract_text("

"), character()) expect_equal(badges_extract_text("

"), character()) # first paragraph contains non-image components expect_equal( badges_extract_text('

altHi!

'), character() ) }) test_that("finds single badge", { expect_equal( badges_extract_text('

'), '' ) }) test_that("finds badges in #badges div", { expect_equal( badges_extract_text('

'), '' ) # even if there's extra text expect_equal( badges_extract_text('

Hi!

'), '' ) }) test_that("can find badges in comments", { html <- '

blop

I am the first paragraph!

' expect_equal(badges_extract_text(html), '') # produced by usethis html <- '

blop

I am the first paragraph!

' expect_equal(badges_extract_text(html), '') }) test_that("ignores extraneous content", { html <- '

blop

I am the first paragraph!

a

B

' expect_equal(badges_extract_text(html), '') })