context("Validate functionality given multiple or single sources")
# Test data
country <- get_headlines(country = "us")
q <- get_headlines(q = "Trump")
category <- get_headlines(category = "politics")
sources<- get_headlines(sources = "bild")
test_that("Validate formal structure as data.frame", {
for (each in list(country, q, category, sources)) {
expect_equal(class(each), "data.frame")
}
})
testthat::test_that("Validate empty headlines as error", {
testthat::expect_error(get_headlines(), "Please pass at least one of the following sources: country, category, sources or q")
})
testthat::test_that("Validate wrong country as error", {
testthat::expect_error(get_headlines(country = "North-Germany"), "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::test_that("Validate wrong category as error", {
testthat::expect_error(get_headlines(category = ""), "category must be one of these: business, entertainment, gaming, general, health-and-medical, music, politics, science-and-nature, sport, technology")
})
testthat::test_that("Validate arguments which you can't mix", {
testthat::expect_error(get_headlines(category = "de", category ="general", sources = "bild"), "you can't mix this param with the country or category params")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.