@@ -34,7 +34,8 @@ struct GlossaryHTMLFormatTests {
3434 term: String = " 映像 " ,
3535 reading: String ? = " えいぞう " ,
3636 dictionaryTitle: String = " Dictionary A " ,
37- dictionaryUUID: UUID = UUID ( )
37+ dictionaryUUID: UUID = UUID ( ) ,
38+ definitions: [ Definition ] = [ . text( " Test definition " ) ]
3839 ) -> SearchResult {
3940 let candidate = LookupCandidate ( from: term)
4041 let rankingCriteria = RankingCriteria (
@@ -55,7 +56,7 @@ struct GlossaryHTMLFormatTests {
5556 candidate: candidate,
5657 term: term,
5758 reading: reading,
58- definitions: [ . text ( " Test definition " ) ] ,
59+ definitions: definitions ,
5960 frequency: nil ,
6061 frequencies: [ ] ,
6162 pitchAccents: [ ] ,
@@ -196,6 +197,80 @@ struct GlossaryHTMLFormatTests {
196197 #expect( html. contains ( " <li data-dictionary= " ) , " Missing li with data-dictionary " )
197198 }
198199
200+ @Test ( " Single dictionary glossary preserves Jitendex sense lists " , . bug( " https://github.com/classicsc/MaruReader/issues/26 " ) )
201+ func singleDictionaryGlossary_preservesJitendexSenseList( ) async throws {
202+ let dictionaryUUID = UUID ( )
203+ let definitionJSON = #"""
204+ {
205+ "type": "structured-content",
206+ "content": {
207+ "tag": "ul",
208+ "data": {"content": "sense-groups"},
209+ "content": {
210+ "tag": "li",
211+ "data": {"content": "sense-group"},
212+ "content": [
213+ {
214+ "tag": "span",
215+ "data": {"class": "tag", "content": "part-of-speech-info"},
216+ "content": "noun"
217+ },
218+ {
219+ "tag": "ol",
220+ "content": {
221+ "tag": "li",
222+ "style": {"listStyleType": "\"①\""},
223+ "data": {"content": "sense"},
224+ "content": {
225+ "tag": "ul",
226+ "data": {"content": "glossary"},
227+ "content": [
228+ {"tag": "li", "content": "major recession"},
229+ {"tag": "li", "content": "serious depression"}
230+ ]
231+ }
232+ }
233+ }
234+ ]
235+ }
236+ }
237+ }
238+ """#
239+ let definition = try JSONDecoder ( ) . decode ( Definition . self, from: Data ( definitionJSON. utf8) )
240+ let result = makeTestSearchResult (
241+ term: " 大不況 " ,
242+ reading: " だいふきょう " ,
243+ dictionaryTitle: " Jitendex " ,
244+ dictionaryUUID: dictionaryUUID,
245+ definitions: [ definition]
246+ )
247+ let dictionaryResults = makeDictionaryResults (
248+ dictionaryTitle: " Jitendex " ,
249+ dictionaryUUID: dictionaryUUID,
250+ searchResults: [ result]
251+ )
252+ let group = makeGroupedSearchResults (
253+ expression: " 大不況 " ,
254+ reading: " だいふきょう " ,
255+ dictionariesResults: [ dictionaryResults]
256+ )
257+ let response = makeTextLookupResponse ( selectedGroup: group)
258+ let resolver = TextLookupResponseTemplateResolver (
259+ response: response,
260+ selectedGroup: group,
261+ selectedDictionaryID: dictionaryUUID
262+ )
263+
264+ let resolved = await resolver. resolve ( . singleDictionaryGlossary( dictionaryID: dictionaryUUID) )
265+ let html = try #require( resolved. text)
266+
267+ #expect( html. contains ( " <ol><li data-dictionary= \" Jitendex \" > " ) )
268+ #expect( html. contains ( " <ul style= \" margin: 0; padding-left: 1.5em; list-style-type: circle; \" > " ) )
269+ #expect( html. contains ( " <ol class= \" gloss-sc-ol \" > " ) )
270+ #expect( html. contains ( " list-style-type: "①" " ) )
271+ #expect( html. contains ( " data-sc-content= \" glossary \" " ) )
272+ }
273+
199274 @Test func singleGlossary_usesFirstDisplayedDictionary( ) async {
200275 let firstDictionary = makeDictionaryResults ( dictionaryTitle: " Dictionary A " )
201276 let secondDictionary = makeDictionaryResults ( dictionaryTitle: " Dictionary B " )
0 commit comments