context("Chart-helpers")
test_chart_path <- file.path(getOption("clickme_templates_path"), "TestChart")
unlink(test_chart_path, recursive = TRUE)
TestChart <- setRefClass('TestChart', contains = "Chart", where=.GlobalEnv)
suppressMessages(new_template("TestChart"))
test_that("get_urls", {
params <- list()
test_chart <- TestChart$new(params)
test_chart$get_params()
test_chart$get_file_structure()
test_chart$get_config()
test_chart$get_urls()
expect_equal(test_chart$internal$url$local, file.path(test_chart$internal$file$paths$output, "temp-TestChart.html"))
expect_equal(test_chart$internal$url$server, "http://localhost:8000/temp-TestChart.html")
})
# I haven't been able to get this test to work, but manually, it works.
# test_that("iframe", {
# params <- list()
# test_chart <- TestChart$new(params)
# test_chart$get_params()
# test_chart$get_file_structure()
# test_chart$get_config()
# test_chart$get_urls()
# iframe <- capture.output(test_chart$iframe()$hide())
# expect_equal(iframe, '<iframe width="1000" height="800" src="temp-TestChart.html" frameborder=0> </iframe>')
# iframe <- capture.output(test_chart$iframe(relative_path = "clickme")$hide())
# expect_equal(iframe, '<iframe width="1000" height="800" src="clickme/temp-TestChart.html" frameborder=0> </iframe>')
# demo_mode(TRUE, iframe_src = "data-src", iframe_height = 800)
# iframe <- capture.output(test_chart$iframe(relative_path = "clickme")$hide())
# expect_equal(iframe, '<iframe width="1000" height="800" data-src="clickme/temp-TestChart.html" frameborder=0> </iframe>')
# demo_mode(FALSE)
# })
test_that("link", {
params <- list()
test_chart <- TestChart$new(params)
test_chart$get_params()
test_chart$get_file_structure()
test_chart$get_config()
test_chart$get_urls()
link <- capture.output(test_chart$link()$hide())
expect_equal(link, '<a href="temp-TestChart.html" class="clickme">TestChart</a>')
link <- capture.output(test_chart$link(class = "oh_my_link")$hide())
expect_equal(link, '<a href="temp-TestChart.html" class="oh_my_link">TestChart</a>')
})
unlink(file.path(getOption("clickme_templates_path"), "TestChart"), recursive = TRUE)
unlink(file.path(getOption("clickme_output_path"), "temp-TestChart.html"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.