Skip to content

Commit 24547a2

Browse files
committed
test: add a test for searchData content
1 parent d4e85e4 commit 24547a2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/ex_doc/formatter/html_test.exs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,26 @@ defmodule ExDoc.Formatter.HTMLTest do
640640
Jason.decode!(content)["extras"]
641641
|> Enum.find(&(&1["id"] == "readme"))
642642
|> Map.fetch!("searchData")
643+
644+
"searchData=" <> content = read_wildcard!(tmp_dir <> "/html/dist/search_data-*.js")
645+
646+
assert [
647+
%{
648+
"doc" => "In this doc we...",
649+
"ref" => "readme.html",
650+
"title" => "top of the doc - readme",
651+
"type" => "custom"
652+
},
653+
%{
654+
"doc" => "Some longer text!\n\nHere it is :)",
655+
"ref" => "readme.html#heading-without-content",
656+
"title" => "custom-text - readme",
657+
"type" => "custom"
658+
}
659+
] =
660+
content
661+
|> Jason.decode!()
662+
|> Map.fetch!("items")
643663
end
644664

645665
test "containing settext headers while discarding links on header",

0 commit comments

Comments
 (0)