tests/testthat/test-jp_labs.R

test_that("jp_labs() modifies Datawrapper chart labels", {
  chart_id <- "6PxkU"

  chart_metadata <- jp_labs(
    chart_id = chart_id,
    title = "West Java: COVID-19 deaths",
    subtitle = paste0(
      "Daily new confirmed deaths* by age group ",
      "(seven-day moving average)"
    ),
    notes = "*Between April 2, 2020, and Oct. 5, 2021",
    source_name = "West Java administration",
    source_url = "https://pikobar.jabarprov.go.id/",
    byline = "@dzulfiqarfr",
    jp_byline_prefix = FALSE,
    alt_text = paste0(
      "A line chart of confirmed COVID-19 deaths in West Java by age group. ",
      "The chart shows that deaths among the elderly did not surge as ",
      "significant as those among residents aged 59 years old or younger ",
      "in July and August, when the delta variant drove the second wave. ",
      "But the province has since recorded improvements."
    )
  )

  expect_s3_class(chart_metadata, "dw_chart")
})
dzulfiqarfr/jpwrapper documentation built on Dec. 20, 2021, 2:20 a.m.