~hrbrmstr/ggchicklet

822c3de6a52d51501309baca44395ba9b135dbd2 — hrbrmstr 4 years ago 54dc044
switch to tinytest
4 files changed, 23 insertions(+), 37 deletions(-)

M DESCRIPTION
R tests/testthat/test-ggchicklet.R => inst/tinytest/test_ggchicklet.R
D tests/test-all.R
A tests/tinytest.R
M DESCRIPTION => DESCRIPTION +9 -20
@@ 3,32 3,21 @@ Type: Package
Title: Create 'Chicklet' (Rounded Segmented Column) Charts
Version: 0.1.0
Date: 2019-06-28
Authors@R: c(
    person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 
           comment = c(ORCID = "0000-0001-5670-2640")),
    person("Antoine", "Bichat", role = "ctb")
  )
Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role =
        c("aut", "cre"), comment = c(ORCID = "0000-0001-5670-2640")),
        person("Antoine", "Bichat", role = "ctb") )
Maintainer: Bob Rudis <bob@rud.is>
Description: Sometimes it is useful to stylize column charts a bit more
    than just bland rectangles. Methods are provided to create rounded
    rectangle segmented column charts (i.e. 'chicklets').
        than just bland rectangles. Methods are provided to create
        rounded rectangle segmented column charts (i.e. 'chicklets').
URL: https://gitlab.com/hrbrmstr/ggchicklet
BugReports: https://gitlab.com/hrbrmstr/ggchicklet/issues
Encoding: UTF-8
License: MIT + file LICENSE
Suggests:
    testthat,
    covr,
    hrbrthemes,
    dplyr,
    forcats,
    knitr,
    rmarkdown
Depends:
    R (>= 3.2.0)
Imports:
    ggplot2,
    grid
Suggests: covr, hrbrthemes, dplyr, forcats, knitr, rmarkdown,
        tinytest
Depends: R (>= 3.2.0)
Imports: ggplot2, grid
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
VignetteBuilder: knitr

R tests/testthat/test-ggchicklet.R => inst/tinytest/test_ggchicklet.R +9 -14
@@ 1,25 1,20 @@
library(ggplot2)

context("chicklet geoms are created properly")
test_that("chicklet geoms are created properly", {
data("debates2019")

  data("debates2019")
spkr_ordr <- aggregate(elapsed ~ speaker, data = debates2019, sum)
spkr_ordr <- spkr_ordr[order(spkr_ordr[["elapsed"]]),]

  spkr_ordr <- aggregate(elapsed ~ speaker, data = debates2019, sum)
  spkr_ordr <- spkr_ordr[order(spkr_ordr[["elapsed"]]),]
debates2019$speaker <- factor(debates2019$speaker, spkr_ordr$speaker)

  debates2019$speaker <- factor(debates2019$speaker, spkr_ordr$speaker)

  ggplot(debates2019) +
ggplot(debates2019) +
  geom_chicklet(aes(speaker, elapsed, group = timestamp, fill = topic)) -> gg

  print(gg)

  ggplot_build(gg) -> gb
print(gg)

  ggplot_gtable(gb) -> gt
ggplot_build(gg) -> gb

  expect_true(all(c("GeomChicklet", "GeomRrect") %in% class(gb$plot$layers[[1]]$geom)))
ggplot_gtable(gb) -> gt

expect_true(all(c("GeomChicklet", "GeomRrect") %in% class(gb$plot$layers[[1]]$geom)))

})

D tests/test-all.R => tests/test-all.R +0 -3
@@ 1,3 0,0 @@
library(testthat)

test_check("ggchicklet")

A tests/tinytest.R => tests/tinytest.R +5 -0
@@ 0,0 1,5 @@

if ( requireNamespace("tinytest", quietly=TRUE) ){
  tinytest::test_package("ggchicklet")
}