Skip to content

Add unit tests for index customization #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/testthat/test-index.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
context("customindex")

test_that("Omitting required template keys produces warnings", {
string <-
"<!DOCTYPE html>
<html>
<head>
{%meta_tags%}
<title>Testing Again</title>
{%favicon%}
{%css_tags%}
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
</footer>
</body>
</html>"

app <- Dash$new()

expect_error(
app$index_string(gsub("\\{\\%config\\%\\}|\\{\\%scripts\\%\\}|\\{\\%app_entry\\%\\}", "", string)),
"Did you forget to include app_entry, config, scripts in your index string?"
)

expect_error(
app$index_string(gsub("\\{\\%scripts\\%\\}", "", string)),
"Did you forget to include scripts in your index string?"
)

expect_error(
app$index_string(gsub("\\{\\%app_entry\\%\\}", "", string)),
"Did you forget to include app_entry in your index string?"
)

expect_error(
app$index_string(gsub("\\{\\%config\\%\\}", "", string)),
"Did you forget to include config in your index string?"
)
})

test_that("Customizing title using `name` produces a warning", {

expect_warning(
Dash$new(name="Testing"),
"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.",
fixed=TRUE
)
})