diff --git a/DESCRIPTION b/DESCRIPTION index fdf1e4b..9c81dcf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,6 +19,8 @@ Imports: tibble, tidyr Suggests: - jsonlite + jsonlite, + testthat (>= 3.0.0) URL: https://rfsaldanha.github.io/rspell/ BugReports: https://github.com/rfsaldanha/rspell/issues +Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..ffe1c1a --- /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(rspell) + +test_check("rspell") diff --git a/tests/testthat/test-check_text.R b/tests/testthat/test-check_text.R new file mode 100644 index 0000000..638d886 --- /dev/null +++ b/tests/testthat/test-check_text.R @@ -0,0 +1,25 @@ +text_string <- "O rato roeu a roupa do rei de roma." + +test_that("expect error if text is not set", { + expect_error(check_text(text = NULL)) +}) + +test_that("expect error if text is not character", { + expect_error(check_text(text = TRUE)) +}) + +test_that("expect error if language is not set", { + expect_error(check_text(text = text_string, language = NULL)) +}) + +test_that("expect error if language is not set", { + expect_error(check_text(text = text_string, language = NULL)) +}) + +test_that("expect error if language if not supported", { + expect_error(check_text(text = text_string, language = "blabla")) +}) + +test_that("expect a tibble as responde", { + expect_true(tibble::is_tibble(check_text(text = text_string, language = "pt-BR"))) +})