Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Sep 29, 2024
1 parent 6cd593f commit 713f72e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/qr_vcard.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ qr_vcard <- function(
) |>
vapply(vcard_wrap, character(1), width = 75) |>
paste(collapse = "\r\n") |>
qr_code(ecl = ecl)
qr_code(ecl = ecl) -> output
class(output) <- c("qr_vcard", class(output))
return(output)
}

#' @importFrom assertthat assert_that is.count is.string noNA
Expand Down
39 changes: 39 additions & 0 deletions tests/testthat/test_e_qr_vcard.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
test_that("qr_vcard()", {
expect_s3_class(qr_vcard(given = "Jane", family = "Doe"), "qr_vcard")
expect_s3_class(
qr_vcard(
given = "Jane", family = "Doe", middle = "J.", prefix = "Dr.",
suffix = "PhD", email = "[email protected]", tel = "+1234567890",
url = "https://jane.doe.com", organisation = "Doe Inc.",
job_title = "CEO", gender = "F", logo = "https://jane.doe.com/logo.png",
photo = "https://jane.doe.com/jane.jpg",
address = c(
street_nr = "123 Main St.", city = "Anytown", region = "NY",
postal_code = "12345", country = "USA"
)
),
"qr_vcard"
)
expect_s3_class(
qr_vcard(
given = "Jane", family = "Doe", middle = c("J.", "J."),
prefix = c("Dr.", "ir."), suffix = c("PhD", "MSc"),
email = c(work = "[email protected]", "[email protected]"), tel = "+1234567890",
url = "https://jane.doe.com", organisation = "Doe Inc.",
job_title = "CEO", gender = "F", logo = "https://jane.doe.com/logo.png",
address = list(
work = c(
street_nr = "123 Main St.", city = "Anytown", region = "NY",
postal_code = "12345", country = "USA", pobox = "PO Box 123"
),
home = c(
street_nr = "321 Main St.", city = "Anytown", region = "NY",
postal_code = "12345", country = "USA"
)
),
photo =
"https://jane.doe.com/public/employees/photos/curriculum_vitae/jane_doe.jpg"
),
"qr_vcard"
)
})

0 comments on commit 713f72e

Please sign in to comment.