Skip to content

Commit

Permalink
Fix structure and matching in extracted tests.
Browse files Browse the repository at this point in the history
Because of how HTML parsing works, we need to guarantee
a root node, so we wrap the input and output in a div. Then,
we include the div in the comparison we do after the fact.

We also compare rendered input to output ignoring
whitespace.
  • Loading branch information
Shadowfiend committed Jun 18, 2014
1 parent 33aa784 commit 5d2cbb2
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,16 @@ object ExtractCssSelectorExamples extends App {
| ""\"$exampleLabel""\" in {
| $setupCode
|
| val input = Html5.parse(""\"$input""\")
| val function = $function
| val output = Html5.parse(""\"$output""\")
| val input = Html5.parse(""\"<div>$input</div>""\")
| val function: (NodeSeq)=>NodeSeq = $function
| val output = Html5.parse(""\"<div>$output</div>""\")
|
| input.map(function) must_== output
| // The function returns a NodeSeq; we assume it will
| // contain a single element and unwrap it.
| input.map { html => function(html) } must beLike {
| case Full(rendered) =>
| rendered must ==/(output.toOption.get)
| }
| }""".stripMargin('|')
}

Expand Down

0 comments on commit 5d2cbb2

Please sign in to comment.