Skip to content

Commit 2c46d9f

Browse files
authored
Add unit tests for index customization (#176)
1 parent 21e78db commit 2c46d9f

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/testthat/test-index.R

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
context("customindex")
2+
3+
test_that("Omitting required template keys produces warnings", {
4+
string <-
5+
"<!DOCTYPE html>
6+
<html>
7+
<head>
8+
{%meta_tags%}
9+
<title>Testing Again</title>
10+
{%favicon%}
11+
{%css_tags%}
12+
</head>
13+
<body>
14+
{%app_entry%}
15+
<footer>
16+
{%config%}
17+
{%scripts%}
18+
</footer>
19+
</body>
20+
</html>"
21+
22+
app <- Dash$new()
23+
24+
expect_error(
25+
app$index_string(gsub("\\{\\%config\\%\\}|\\{\\%scripts\\%\\}|\\{\\%app_entry\\%\\}", "", string)),
26+
"Did you forget to include app_entry, config, scripts in your index string?"
27+
)
28+
29+
expect_error(
30+
app$index_string(gsub("\\{\\%scripts\\%\\}", "", string)),
31+
"Did you forget to include scripts in your index string?"
32+
)
33+
34+
expect_error(
35+
app$index_string(gsub("\\{\\%app_entry\\%\\}", "", string)),
36+
"Did you forget to include app_entry in your index string?"
37+
)
38+
39+
expect_error(
40+
app$index_string(gsub("\\{\\%config\\%\\}", "", string)),
41+
"Did you forget to include config in your index string?"
42+
)
43+
})
44+
45+
test_that("Customizing title using `name` produces a warning", {
46+
47+
expect_warning(
48+
Dash$new(name="Testing"),
49+
"The supplied application title, 'Testing', should be set using the title() method, or passed via index_string() or interpolate_index(); it has been ignored, and 'dash' will be used instead.",
50+
fixed=TRUE
51+
)
52+
})

0 commit comments

Comments
 (0)