Skip to content

Commit

Permalink
tests: Test replacing existing bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorld committed Mar 28, 2024
1 parent 1066953 commit 8620f49
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/testthat/test-bookmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ test_that("set_bookmarks_gs", {
# Does Unicode work
skip_if_not(l10n_info()[["UTF-8"]])
skip_on_os("mac") # CRAN checks on macOS 14
bookmarks <- data.frame(title = c("R\u5f88\u68d2\uff01", "Page 1", "Page 2"),
level = c(1, 2, 2),
page = c(1L, 1L, 2L))
set_bookmarks_gs(bookmarks, f1, f2)
bm <- get_bookmarks(f2)[[1]]
expect_equal(bm$title[1], "R\u5f88\u68d2\uff01")

# input = output
bookmarks <- data.frame(title = c("R\u5f88\u68d2\uff01", "Page 1", "Page 2"),
level = c(1, 2, 2),
page = c(1L, 1L, 2L))
set_bookmarks_gs(bookmarks, f2, f2)
bm <- get_bookmarks(f2)[[1]]
expect_equal(bm$title[1], "R\u5f88\u68d2\uff01")

# Edit bookmarks of file with pre-existing bookmarks
f3 <- tempfile(fileext = ".pdf")
on.exit(unlink(f3))
bookmarks <- data.frame(title = c("Page 1", "Page 2"),
page = c(1L, 2L))
set_bookmarks_gs(bookmarks, f2, f3)
expect_equal(nrow(get_bookmarks(f3)[[1]]), 2L)
})

test_that("bookmarks_pdftk", {
Expand Down Expand Up @@ -136,6 +136,14 @@ test_that("bookmarks_pdftk", {
fontface = c("italic", "bold", "plain"),
color = c("black", "blue", "red"))
expect_snapshot(set_bookmarks_pdftk(bookmarks, f1, f2))

# Edit bookmarks of file with pre-existing bookmarks
f3 <- tempfile(fileext = ".pdf")
on.exit(unlink(f3))
bookmarks <- data.frame(title = c("Page 1", "Page 2"),
page = c(1L, 2L))
set_bookmarks_pdftk(bookmarks, f2, f3)
expect_equal(nrow(get_bookmarks(f3)[[1]]), 2L)
})

test_that("bookmarks_pdftools", {
Expand Down

0 comments on commit 8620f49

Please sign in to comment.