@@ -41,6 +41,12 @@ class SiteGeneratationTest:
41
41
val found = d.select(selector).eachText.asScala
42
42
assertEquals(niceMsg(s " Context does not match for ' $selector' " ), expected.toList, found.toList)
43
43
44
+ def assertAttr (selector : String , attr : String , expected : String * ) =
45
+ assertFalse(niceMsg(" Selector not found" ), d.select(selector).isEmpty)
46
+ val found = d.select(selector).eachAttr(attr).asScala
47
+ assertEquals(niceMsg(s " Attribute $attr does not match for ' $selector' " ), expected.toList, found.toList)
48
+
49
+
44
50
def withHtmlFile (path : Path )(op : DocumentContext => Unit ) = {
45
51
assertTrue(s " File at $path does not exisits! " , Files .exists(path))
46
52
val content = new String (Files .readAllBytes(path), Charset .defaultCharset())
@@ -51,21 +57,29 @@ class SiteGeneratationTest:
51
57
@ Test
52
58
def basicTest () = withGeneratedSite(testDocPath.resolve(" basic" )){ dest =>
53
59
54
- def checkFile (path : String )(title : String , header : String , parents : Seq [String ] = Nil ) =
55
- withHtmlFile(dest.resolve(path)){ content =>
56
- content.assertTextsIn(" .projectName" , projectName)
57
- content.assertTextsIn(" .projectVersion" , projectVersion)
58
- content.assertTextsIn(" h1" , header)
59
- content.assertTextsIn(" title" , title)
60
- content.assertTextsIn(" .breadcrumbs a" , (parents :+ title):_* )
61
- }
60
+ def checkFile (path : String )(
61
+ title : String ,
62
+ header : String ,
63
+ parents : Seq [String ] = Nil ,
64
+ checks : DocumentContext => Unit = _ => ()) =
65
+ withHtmlFile(dest.resolve(path)){ content =>
66
+ content.assertTextsIn(" .projectName" , projectName)
67
+ content.assertTextsIn(" .projectVersion" , projectVersion)
68
+ content.assertTextsIn(" h1" , header)
69
+ content.assertTextsIn(" title" , title)
70
+ content.assertTextsIn(" .breadcrumbs a" , (parents :+ title):_* )
71
+ checks(content)
72
+ }
62
73
63
- checkFile(" index.html" )(title = " Basic test" , header = " Header" , parents = Seq (projectName))
74
+ def indexLinks (content : DocumentContext ) =
75
+ content.assertAttr(" p a" ," href" , " docs/index.html" ," docs/index.html" )
76
+
77
+ checkFile(" index.html" )(title = " Basic test" , header = " Header" , parents = Seq (projectName), indexLinks)
64
78
checkFile(" docs/Adoc.html" )(title = " Adoc" , header = " Header in Adoc" , parents = Seq (projectName))
65
79
checkFile(" docs/Adoc.html" )(title = " Adoc" , header = " Header in Adoc" , parents = Seq (projectName))
66
80
checkFile(" docs/dir/index.html" )(title = " A directory" , header = " A directory" , parents = Seq (projectName))
67
81
checkFile(" docs/dir/nested.html" )(
68
82
title = " Nested in a directory" , header = " Nested in a directory" , parents = Seq (projectName, " A directory" ))
69
83
70
84
checkFile(" docs/index.html" )(title = projectName, header = s " $projectName in header " )
71
- }
85
+ }
0 commit comments