diff --git a/Tests/MaakuTests/Core/Container/ListItemSpec.swift b/Tests/MaakuTests/Core/Container/ListItemSpec.swift index 5157a06..bfdd0ab 100644 --- a/Tests/MaakuTests/Core/Container/ListItemSpec.swift +++ b/Tests/MaakuTests/Core/Container/ListItemSpec.swift @@ -13,6 +13,7 @@ import XCTest class ListItemSpec: QuickSpec { + // swiftlint:disable function_body_length override func spec() { describe("ListItem") { @@ -31,7 +32,7 @@ class ListItemSpec: QuickSpec { it("parses the list items") { expect(document[0]).to(beAKindOf(UnorderedList.self)) - // swiftlint:disable force_cast + // swiftlint:disable:next force_cast let list = document[0] as! UnorderedList expect(list.items.count).to(equal(3)) @@ -45,6 +46,89 @@ class ListItemSpec: QuickSpec { } } } + describe("ListItem.attributedText") { + let text = +""" +- list 1 + a paragraph inside list one, followed by: + - embedded list + - another embedded item + 1. ordered list inside + 1. another ordered item + - third embedded item +- second item in top list +""" +/* XML for above for comparison of the structure: + + + + + list 1 + + a paragraph inside list one, followed by: + + + + + embedded list + + + + + another embedded item + + + + + ordered list inside + + + + + another ordered item + + + + + + + third embedded item + + + + + + + second item in top list + + + + + + */ + // We expect that the attributed text for the first item includes all the sub-lists that are included + // under the item, not just the first line ("list 1") or even just the first line and the following + // paragraph, but *all* the stuff inside this list item. + // swiftlint:disable:next line_length + let expectedFirstString = "list 1 a paragraph inside list one, followed by:• embedded list• another embedded item1. ordered list inside2. another ordered item• third embedded item" + + do { + let document = try Document(text: text) + let style = DefaultStyle() + + it("checks the attributedText values") { + // swiftlint:disable:next force_cast + let list = document[0] as! UnorderedList + let firstItemText = list.items[0].attributedText(style: style) + expect(firstItemText.string).to(equal(expectedFirstString)) + } + } catch let error { + it("fails to initialize the document") { + fail("\(error.localizedDescription)") + } + } + + } } }