@@ -38,6 +38,32 @@ class SidebarParserTest:
38
38
| - page: my-page6/my-page6/my-page6.md
39
39
""" .stripMargin
40
40
41
+ private val sidebarNoTitle =
42
+ """ index: index.md
43
+ |subsection:
44
+ | page: my-page1.md
45
+ | - page: my-page2.md
46
+ | - page: my-page3/subsection
47
+ | - title: Reference
48
+ | subsection:
49
+ | - page: my-page3.md
50
+ | hidden: true
51
+ | - index: my-page4/index.md
52
+ | subsection:
53
+ | - page: my-page4/my-page4.md
54
+ | - title: My subsection
55
+ | index: my-page5/index.md
56
+ | subsection:
57
+ | - page: my-page5/my-page5.md
58
+ | - subsection:
59
+ | - page: my-page7/my-page7.md
60
+ | - index: my-page6/index.md
61
+ | subsection:
62
+ | - index: my-page6/my-page6/index.md
63
+ | subsection:
64
+ | - page: my-page6/my-page6/my-page6.md
65
+ """ .stripMargin
66
+
41
67
private val sidebarErrorNoPage =
42
68
""" index: index.md
43
69
|subsection:
@@ -64,13 +90,11 @@ class SidebarParserTest:
64
90
| - page: my-page6/my-page6/my-page6.md
65
91
""" .stripMargin
66
92
67
- private val msgNoTitle = " Error parsing YAML configuration file: Title is not provided."
68
- private val msgNoPage = " Error parsing YAML configuration file: Index or page path to at least one page is missing ."
93
+ private val msgNoTitle = " Error parsing YAML configuration file: 'title' is not provided."
94
+ private val msgNoPage = " Error parsing YAML configuration file: 'index' or ' page' path is missing for title 'My title' ."
69
95
70
96
private def schemaMessage : String = Sidebar .schemaMessage
71
97
72
- private val noPageExpectedError = s " $msgNoPage\n $schemaMessage\n Page my-page2.md does not exist. \n Page my-page3/subsection does not exist. \n Page my-page3.md does not exist. \n Page my-page4/my-page4.md does not exist. \n Page my-page5/my-page5.md does not exist. \n Page my-page7/my-page7.md does not exist. \n Page my-page6/my-page6/my-page6.md does not exist. "
73
-
74
98
@ Test
75
99
def loadSidebar (): Unit = assertEquals(
76
100
Sidebar .Category (
@@ -92,10 +116,23 @@ class SidebarParserTest:
92
116
)
93
117
94
118
@ Test
95
- def loadSidebarError () : Unit =
119
+ def loadSidebarNoPageError : Unit =
96
120
val out = new ByteArrayOutputStream ()
97
121
Console .withErr(new PrintStream (out)) {
98
122
Sidebar .load(sidebarErrorNoPage)(using testContext)
99
123
}
124
+ println(out.toString())
100
125
val error = out.toString().trim()
101
- assertEquals(noPageExpectedError, error)
126
+
127
+ assert(error.contains(msgNoPage) && error.contains(schemaMessage))
128
+
129
+
130
+ @ Test
131
+ def loadSidebarNoTitleError (): Unit =
132
+ val out = new ByteArrayOutputStream ()
133
+ Console .withErr(new PrintStream (out)) {
134
+ Sidebar .load(sidebarNoTitle)(using testContext)
135
+ }
136
+ val error = out.toString().trim()
137
+
138
+ assert(error.contains(msgNoTitle) && error.contains(schemaMessage))
0 commit comments