test_that("read zero length", {
expect_identical(
read_opening_hours(character(0)),
tibble::tibble(
Name = character(0),
String = character(0),
OpeningHours = list()
)
)
})
test_that("read 9:00-17:00", {
expect_identical(read_opening_hours("9:00-17:00"), structure(list(Name = "1", String = "9:00-17:00", OpeningHours = list(
structure(list(Open = structure(32400, units = "secs", class = c(
"hms",
"difftime"
)), Close = structure(61200, units = "secs", class = c(
"hms",
"difftime"
))), row.names = c(NA, -1L), class = c(
"tbl_df",
"tbl", "data.frame"
))
)), row.names = c(NA, -1L), class = c(
"tbl_df",
"tbl", "data.frame"
)))
})
test_that("read names", {
x <- "9:00-17:00"
names(x) <- "Store"
x <- read_opening_hours(x)
x <- tidyr::unnest(x, "OpeningHours")
expect_identical(x, tibble::tibble(
Name = "Store",
String = "9:00-17:00",
Open = hms::parse_hm("9:00"),
Close = hms::parse_hm("17:00")
))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.