library(adParser)
library(testthat)
context("Parser functions")
test_that("get attributes",
{
page <- xml2::read_html(
"../../inst/rawdata/webpages/gumtree-cat-1-1-2015-10-08.html")
expect_equal(
get_attribute(page, "#ad-title"),
"Beautiful Blue Point Birman boy & Gorgeous Seal point Birman Girl")
})
test_that("get lat long works",
{
page <- xml2::read_html(
"../../inst/rawdata/webpages/gumtree-cat-1-1-2015-10-08.html")
tmp <- get_lat_long(page)
expect_equal(tmp, c("-26.8979445","152.9589234"))
})
test_that("get data listed works",
{
page <- xml2::read_html(
"../../inst/rawdata/webpages/gumtree-cat-1-1-2015-10-08.html")
tmp <- get_date_listed(page)
expect_equal(tmp, "06/10/2015")
})
test_that("clean string works",
{
expect_equal(clean_string("bob\r\n"), "bob")
expect_equal(clean_string("\n\nbob"), "bob")
expect_equal(clean_string("bob "), "bob")
expect_equal(clean_string("bob bob "), "bob bob")
expect_equal(clean_string("bob bob "), "bob bob")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.