1test_that('A basic tag works', {
2	r <- repr_html(htmltools::div())
3	expect_identical(r, sprintf(repr:::HTML_SKELETON, '', '<div></div>'))
4})
5
6test_that('A basic widget works', {
7	skip_if_not_installed('stringr')
8	skip_if_not_installed('htmlwidgets')
9
10	r <- repr_html(stringr::str_view('xy', 'y'))
11	expect_match(r, "x<span class='match'>y<\\/span>", fixed = TRUE, all = FALSE)
12})
13
14test_that('Dependencies work', {
15	skip_if_not_installed('stringr')
16	skip_if_not_installed('htmlwidgets')
17
18	r <- repr_html(stringr::str_view('xy', 'y'))
19	expect_match(r, '<script title="htmlwidgets" src="data:application/javascript', fixed = TRUE, all = FALSE)
20})
21
22test_that('The dependency manager works', {
23	skip_if_not_installed('stringr')
24	skip_if_not_installed('htmlwidgets')
25
26	o <- options(repr.html.deduplicate = TRUE)
27	on.exit(options(o))
28	html_dependencies$clear()
29
30	r <- repr_html(stringr::str_view('xy', 'y'))
31	expect_match(r, '<meta charset="utf-8">\n\t\t<script', fixed = TRUE, all = FALSE)
32
33	r <- repr_html(stringr::str_view('xy', 'y'))
34	expect_match(r, '<meta charset="utf-8">\n\t\t\n', fixed = TRUE, all = FALSE)  #no deps here
35})
36
37test_that('Leaflet HTML and deps can be represented', {
38	skip_if_not_installed('leaflet')
39
40	leaf <- leaflet::addTiles(leaflet::leaflet())
41
42	r <- repr_html(leaf)
43	expect_match(r, '<script title="htmlwidgets" src="data:')
44})
45