From 102d1bf8aa236b764ee2ad7a93de5e27f4c865c0 Mon Sep 17 00:00:00 2001 From: Ernest Guevarra Date: Tue, 12 Mar 2024 06:17:12 +0000 Subject: [PATCH] tests for paleta --- DESCRIPTION | 6 +++--- R/theme_paleta.R | 2 +- tests/testthat.R | 12 ++++++++++++ tests/testthat/test-theme_paleta.R | 13 +++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-theme_paleta.R diff --git a/DESCRIPTION b/DESCRIPTION index dd55849..fc65699 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,8 @@ Imports: Suggests: knitr, rmarkdown, - spelling + spelling, + testthat (>= 3.0.0) Encoding: UTF-8 Language: en-GB LazyData: true @@ -32,5 +33,4 @@ Roxygen: list(markdown = TRUE) URL: https://github.com/katilingban/paleta,http://katilingban.io/paleta/ BugReports: https://github.com/katilingban/paleta/issues VignetteBuilder: knitr - - +Config/testthat/edition: 3 diff --git a/R/theme_paleta.R b/R/theme_paleta.R index 3708ead..61c1db0 100644 --- a/R/theme_paleta.R +++ b/R/theme_paleta.R @@ -128,7 +128,7 @@ set_paleta_font <- function() { #' @param axis Add x or y axes? `TRUE`, `FALSE`, "`xy`". Default is FALSE. #' @param ticks Logical. Should ticks be added? Default is FALSE. #' -#' @return A [ggplot2] theme. +#' @returns A [ggplot2] theme. #' theme_paleta <- function(base_family = set_paleta_font(), base_size = 11.5, diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..4b3b9d3 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(paleta) + +test_check("paleta") diff --git a/tests/testthat/test-theme_paleta.R b/tests/testthat/test-theme_paleta.R new file mode 100644 index 0000000..c3f71d7 --- /dev/null +++ b/tests/testthat/test-theme_paleta.R @@ -0,0 +1,13 @@ +# Test paleta ------------------------------------------------------------------ + +## Test paleta_fonts class +testthat::expect_type(paleta_fonts, "list") + +## Test length of paleta fonts +testthat::expect_equal(length(paleta_fonts), 3) + +## Test output of set_paleta_font +testthat::expect_type(set_paleta_font(), "character") +testthat::expect_equal(length(set_paleta_font()), 1) + +