Skip to content

Commit

Permalink
up test
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherkenny committed Dec 6, 2024
1 parent 05264db commit 1599620
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/testthat/test-create.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
test_that("og_create works", {
expect_equal(2 * 2, 4)
expect_equal(
og_create(
title = 'Process the Open Graph Protocol',
type = 'website',
image = 'http://christophertkenny.com/opengraph/logo.png',
url = 'https://christophertkenny.com/opengraph/',
description = 'Parse metadata on websites which use the Open Graph Protocol.'
),
c("<meta property=\"og:title\" content=\"Process the Open Graph Protocol\">",
"<meta property=\"og:type\" content=\"website\">", "<meta property=\"og:image\" content=\"http://christophertkenny.com/opengraph/logo.png\">",
"<meta property=\"og:url\" content=\"https://christophertkenny.com/opengraph/\">",
"<meta property=\"og:description\" content=\"Parse metadata on websites which use the Open Graph Protocol.\">"
)
)

expect_error(og_create(), '`title` is required.')
expect_error(og_create(title = 'foo'), '`type` is required.')
expect_error(og_create(title = 'foo', type = 'bar'), '`image` is required.')
expect_error(og_create(title = 'foo', type = 'bar', image = 'img'), '`url` is required.')
})
1 change: 1 addition & 0 deletions tests/testthat/test-parse.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test_that('og_parse works', {
expect_true(is.vector(og_parse('https://www.rstudio.com')))
expect_true(length(og_parse('https://www.christophertkenny.com/testtesttest')) == 0)
})
8 changes: 8 additions & 0 deletions tests/testthat/test-validate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("og_validate() works", {

web <- og_parse('https://www.rstudio.com')

skip_if(length(web) == 0)

expect_equal(og_validate(web), TRUE)
})

0 comments on commit 1599620

Please sign in to comment.