Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jenisayshi committed Sep 4, 2024
1 parent 5a1f7f1 commit 7ef4a41
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
8 changes: 8 additions & 0 deletions tests/testthat/test-clean_heading_text.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("clean heading text", {
clean_heading_check <- clean_heading_text("This is my clean heading link!")

expect_equal(
"this_is_my_clean_heading_link",
clean_heading_check
)
})
28 changes: 24 additions & 4 deletions tests/testthat/test-contents_links.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
# Check contents link
test_that("contents_link", {
contents_check <- contents_links("Test content link", "test_content_link")

expect_equal(
"test_content_link",
contents_links("Test content link", "test_content_link")$children[[1]]$attribs$id
)
expect_equal("test_content_link", contents_check$children[[1]]$attribs$id)
})


# Check subcontents in contents link
test_that("subcontents in contents_link", {
contents_check <- contents_links("Test content link",
"test_content_link",
c("My test", "Subcontents", "Links"))

expect_equal("#my_test",
contents_check$children[[2]]$children[[1]][[1]]$children[[2]]$attribs$href)
})

# Check custom subcontents links
test_that("custom subcontents in contents_link", {
contents_check <- contents_links("Test content link",
"test_content_link",
c("My test", "Subcontents", "Links"),
c(NA, NA, "my_custom_link"))

expect_equal("#my_custom_link",
contents_check$children[[2]]$children[[1]][[3]]$children[[2]]$attribs$href)
})
11 changes: 6 additions & 5 deletions tests/testthat/test-subcontents_links.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#Test custom links
test_that("subcontents_links", {
subcontents_check <- subcontents_links(c("Here are my", "Subcontents Links!"),
c(NA, NA))
subcontents_check <-
subcontents_links(c("Here are my", "Subcontents Links!"), c(NA, NA))

expect_identical(subcontents_check$children[[1]][[2]]$children[[2]]$attribs$href,
"#subcontents_links")
})




# Test custom subcontents links
test_that("custom subcontents_links", {
custom_subcontents_check <- subcontents_links(c("Here are my", "Subcontents Links!"),
c(NA, "custom_link"))
custom_subcontents_check <-
subcontents_links(c("Here are my", "Subcontents Links!"), c(NA, "custom_link"))

expect_identical(custom_subcontents_check$children[[1]][[2]]$children[[2]]$attribs$href,
"#custom_link")
Expand Down

0 comments on commit 7ef4a41

Please sign in to comment.