Skip to content

Commit

Permalink
Fix test output for html/f004 for default extractAllScripts to false.
Browse files Browse the repository at this point in the history
Add html/f005 with extractAllScripts set to true.

For #603.
  • Loading branch information
gkellogg committed Oct 25, 2024
1 parent b8ac517 commit 11e6c7d
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 5 deletions.
38 changes: 37 additions & 1 deletion tests/html-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ <h2>
</dl>
</dd>
<dt id='tf004'>
Test tf004 Flattens all script elements by default
Test tf004 Flattens first script element by default
</dt>
<dd>
<dl class='entry'>
Expand Down Expand Up @@ -1015,6 +1015,42 @@ <h2>
</dd>
</dl>
</dd>
<dt id='tf005'>
Test tf005 Flattens all script elements if extractAllScripts set to true
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tf005</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:FlattenTest, jld:HtmlTest</dd>
<dt>Purpose</dt>
<dd>Tests embedded JSON-LD in HTML multiple script elements</dd>
<dt>input</dt>
<dd>
<a href='html/f005-in.html'>html/f005-in.html</a>
</dd>
<dt>context</dt>
<dd>
<a href='html/f005-context.jsonld'>html/f005-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='html/f005-out.jsonld'>html/f005-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
<dt>processorFeature</dt>
<dd>HTML Script Extraction</dd>
<dt>extractAllScripts</dt>
<dd>true</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tr001'>
Test tr001 Transforms embedded JSON-LD script element
</dt>
Expand Down
15 changes: 14 additions & 1 deletion tests/html-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,25 @@
}, {
"@id": "#tf004",
"@type": ["jld:PositiveEvaluationTest", "jld:FlattenTest", "jld:HtmlTest"],
"name": "Flattens all script elements by default",
"name": "Flattens first script element by default",
"purpose": "Tests embedded JSON-LD in HTML multiple script elements",
"input": "html/f004-in.html",
"context": "html/f004-context.jsonld",
"expect": "html/f004-out.jsonld",
"option": {"specVersion": "json-ld-1.1", "processorFeature": "HTML Script Extraction"}
}, {
"@id": "#tf005",
"@type": ["jld:PositiveEvaluationTest", "jld:FlattenTest", "jld:HtmlTest"],
"name": "Flattens all script elements if extractAllScripts set to true",
"purpose": "Tests embedded JSON-LD in HTML multiple script elements",
"input": "html/f005-in.html",
"context": "html/f005-context.jsonld",
"expect": "html/f005-out.jsonld",
"option": {
"specVersion": "json-ld-1.1",
"processorFeature": "HTML Script Extraction",
"extractAllScripts": true
}
}, {
"@id": "#tr001",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest", "jld:HtmlTest"],
Expand Down
4 changes: 1 addition & 3 deletions tests/html/f004-out.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"foo": {"@id": "http://example.com/foo", "@container": "@list"}
},
"@graph": [
{"@id": "_:b0", "foo": ["bar"]},
{"@id": "_:b1", "ex:foo": "foo"},
{"@id": "_:b2", "ex:bar": "bar"}
{"@id": "_:b0", "foo": ["bar"]}
]
}
6 changes: 6 additions & 0 deletions tests/html/f005-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"ex": "http://example.com/",
"foo": {"@id": "http://example.com/foo", "@container": "@list"}
}
}
18 changes: 18 additions & 0 deletions tests/html/f005-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>
<head>
<script type="application/ld+json">
{
"@context": {
"foo": {"@id": "http://example.com/foo", "@container": "@list"}
},
"foo": [{"@value": "bar"}]
}
</script>
<script type="application/ld+json">
[
{"http://example.com/foo": {"@value": "foo"}},
{"http://example.com/bar": {"@value": "bar"}}
]
</script>
</head>
</html>
11 changes: 11 additions & 0 deletions tests/html/f005-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": {
"ex": "http://example.com/",
"foo": {"@id": "http://example.com/foo", "@container": "@list"}
},
"@graph": [
{"@id": "_:b0", "foo": ["bar"]},
{"@id": "_:b1", "ex:foo": "foo"},
{"@id": "_:b2", "ex:bar": "bar"}
]
}

0 comments on commit 11e6c7d

Please sign in to comment.