From c6187f1d48e42e738ce68ab6a0dbbdce37260e5f Mon Sep 17 00:00:00 2001 From: Ernest Guevarra Date: Tue, 12 Mar 2024 09:35:49 +0000 Subject: [PATCH] create tests for utils functions --- tests/testthat/test-utils.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 35950b6..17aff66 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,3 +1,34 @@ # Tests for utility functions -------------------------------------------------- +## Test get colours function ---- testthat::expect_type(get_colours(pattern = "Blue"), "character") +testthat::expect_type(get_colours(pattern = "Blue", named = TRUE), "character") +testthat::expect_type(tint_colour(acdc_green, p = 0.2), "character") + + +## Test tint colours function ---- +testthat::expect_type(tint_colours(c(acdc_green, acdc_gold), p = 0.2), "list") +testthat::expect_type(tint_colours(c(acdc_green, acdc_gold), p = c(0.2, 0.4)), "list") +testthat::expect_equal( + tint_colours( + c(acdc_green, acdc_gold), + p = c(0.2, 0.4) + ) |> + (\(x) x[[1]])() |> + length(), + 2 +) + + +## Test shade colours function ---- +testthat::expect_type(shade_colours(c(acdc_green, acdc_gold), p = 0.2), "list") +testthat::expect_type(shade_colours(c(acdc_green, acdc_gold), p = c(0.2, 0.4)), "list") +testthat::expect_equal( + shade_colours( + c(acdc_green, acdc_gold), + p = c(0.2, 0.4) + ) |> + (\(x) x[[1]])() |> + length(), + 2 +)