source("library.R")
context("Validate functionality given multiple or single sources")
# Test data
ld <- get_sources()
cle <- get_sources(country = "us", language = "en")
cld <- get_sources(category = "general", language = "de")
clc <- get_sources(category = "politics")
test_that("Validate formal structure as data.frame", {
skip_on_cran()
for (each in list(ld, cle, cld, clc)) {
expect_equal(class(each), "data.frame")
}
})
testthat::test_that("Validate warnings", {
skip_on_cran()
testthat::expect_warning(get_sources(), "Please pass one of the following sources: category, language, country. Otherwise all sources are displayed.")
})
testthat::test_that("Validate errors", {
skip_on_cran()
testthat::expect_error(get_sources(language = ""), "language must be one of these: ar, en, cn, de, es, fr, he, it, nl, no, pt, ru, sv, ud")
testthat::expect_error(get_sources(country = ""), "country must be one of these:, ar, au, br, ca, cn, de, es, fr, gb, hk, ie, in, is, it, nl, no, pk, ru, sa, sv, us, za")
testthat::expect_error(get_sources(category = ""), "category must be one of these: business, entertainment, gaming, general, health-and-medical, music, politics, science-and-nature, sport, technology")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.