Skip to content

Commit

Permalink
unit tests for conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjohnst86 committed May 30, 2019
1 parent f798d70 commit 63f8804
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/testthat/test-slides.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
context("Extracting, parsing, and modifying the slides")


# chpt_text <-
# readr::read_lines("tests/testthat/chapter1.md")
# dc_slides_to_text_doc("tests/testthat/chapter_1_video_1.md")
chpt1_slide1 <- readr::read_lines("chapter_1_video_1.md")

slide_file <- "chapter_1_video_1.md"

test_that("projector key is extracted", {
key <- sld_extract_key(slide_file)

expect_equal(length(key), 1)
})

test_that("slides (as text) parsed and converted", {
new <- str_c(fs::path_ext_remove(slide_file), "-tutorial.Rmd")
converted_slides <- dc_slides_to_text_doc(slide_file)
expect_type(converted_slides, "character")
expect_true(any(str_detect(converted_slides, "``` r")))
expect_true(sum(str_detect(converted_slides, "\\{\\{[:digit:]+\\}\\}")) == 0)

utils_write_file(converted_slides, new)
expect_true(fs::file_exists(new))
})

0 comments on commit 63f8804

Please sign in to comment.