library(testthat)
library(readr)
library(lubridate)
library(here)
library(stringr)
library(purrr)
library(rprojroot)
context("Testing that journal files are correct")
# Freeform test ----------------------------------------
# Expectations
freeform_actual <- journal_freeform(ymd(20190101), ymd(20190228))
freeform_actual_contents <- paste0(freeform_actual$file_contents[1], "\n")
freeform_expected_contents <- seq(ymd(20190101), by = 1, length.out = 31) %>%
format_date() %>%
paste0("## ", ., "\n\n* \n\n") %>%
paste(sep = "", collapse = "") %>%
paste0("# January 2019\n\n", .)
test_that("Freeform journal contents are correct",{
expect_identical(freeform_actual_contents, freeform_expected_contents)
})
freeform_actual_filename <- freeform_actual$filename[1]
test_that("Freeform journal filenames are correct",{
expect_identical(freeform_actual_filename, "2019-01-freeform.md")
})
# Tactics test -----------------------------------------------
tactics <- read_file(is_testthat$find_file("tactics.md"))
tactics_actual <- journal_tactics(tactics, ymd(20190401), ymd(20190414))
tactics_actual_contents <- tactics_actual$file_contents[1]
tactics_repeat <- seq(ymd(20190401), by = 1, length.out = 7) %>%
format_date() %>%
paste0("### ", ., " (<YES/NO/SKIP>)\n\n* \n\n") %>%
paste(sep = "", collapse = "")
tactics_expected_contents <- paste0("# Week 1: Mon 01 Apr 2019 to Sun 07 Apr 2019\n\n",
"## Complete devotion SOP for 45 minutes\n\n",
tactics_repeat, "\n",
"## Read for 15 minutes\n\n",
tactics_repeat)
test_that("Tactics journal contents are correct",{
expect_identical(tactics_actual_contents, tactics_expected_contents)
})
tactics_actual_filename <- tactics_actual$filename[1]
test_that("Tactics journal filenames are correct",{
expect_identical(tactics_actual_filename, "~w1-tactics.md")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.