Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/TextBuilder/TextBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct TextBuilderWith<Separator: TextBuilderSeparator> {
}

public static func buildArray(_ components: [Text?]) -> Text? {
components.lazy.compactMap { $0 }.joined(separator: Separator.separator.map(Text.init))
components.lazy.compactMap { $0 }.joined(separator: Separator.separator.map { Text($0) })
}

@inlinable
Expand Down
10 changes: 5 additions & 5 deletions Tests/TextBuilderTests/TextBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest

final class TextBuilderTests: XCTestCase {
func testBasicTextBuilder() {
XCTAssertNoDifference(
expectNoDifference(
basicTextBuilderText(),
Text("Lorem").underline().foregroundColor(.blue) +
Text("ipsum dolor") +
Expand All @@ -15,7 +15,7 @@ final class TextBuilderTests: XCTestCase {
}

func testSpacedTextBuilder() {
XCTAssertNoDifference(
expectNoDifference(
spacedTextBuilderText(),
Text("Lorem").underline().foregroundColor(.blue) +
Text(verbatim: " ") +
Expand All @@ -28,7 +28,7 @@ final class TextBuilderTests: XCTestCase {
}

func testMultilineTextBuilder() {
XCTAssertNoDifference(
expectNoDifference(
multilineTextBuilderText(),
Text("Lorem").underline().foregroundColor(.blue) +
Text(verbatim: "\n") +
Expand All @@ -41,7 +41,7 @@ final class TextBuilderTests: XCTestCase {
}

func testCustomTextBuilder() {
XCTAssertNoDifference(
expectNoDifference(
customTextBuilderText(),
Text("Lorem").underline().foregroundColor(.blue) +
Text(verbatim: " 🍆 ") +
Expand All @@ -54,7 +54,7 @@ final class TextBuilderTests: XCTestCase {
}

func testComplexTextBuilder() {
XCTAssertNoDifference(
expectNoDifference(
complexTextBuilderText(),
Text(verbatim: "Lorem").underline().foregroundColor(.blue) +
Text(verbatim: " ") +
Expand Down
22 changes: 11 additions & 11 deletions Tests/TextBuilderTests/TextExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest

final class TextExtensionsTests: XCTestCase {
func testJoined_noSeparator() {
XCTAssertNoDifference(
expectNoDifference(
textArray.joined(),
Text("Lorem").underline().foregroundColor(.blue) +
Text("ipsum dolor") +
Expand All @@ -15,7 +15,7 @@ final class TextExtensionsTests: XCTestCase {
}

func testJoined_spaceSeparator() {
XCTAssertNoDifference(
expectNoDifference(
textArray.joined(separator: Text(" ")),
Text("Lorem").underline().foregroundColor(.blue) +
Text(" ") +
Expand All @@ -28,7 +28,7 @@ final class TextExtensionsTests: XCTestCase {
}

func testJoined_formattedSeparator() {
XCTAssertNoDifference(
expectNoDifference(
textArray.joined(separator: Text(" ** ").italic().foregroundColor(.green)),
Text("Lorem").underline().foregroundColor(.blue) +
Text(" ** ").italic().foregroundColor(.green) +
Expand All @@ -41,14 +41,14 @@ final class TextExtensionsTests: XCTestCase {
}

func testInit_noSeparator() {
XCTAssertNoDifference(
expectNoDifference(
Text(content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text("ipsum dolor") +
Text("sit").bold() +
Text("amet, consectetur")
)
XCTAssertNoDifference(
expectNoDifference(
Text(separator: nil, content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text("ipsum dolor") +
Expand All @@ -58,7 +58,7 @@ final class TextExtensionsTests: XCTestCase {
}

func testInit_blankSeparator() {
XCTAssertNoDifference(
expectNoDifference(
Text(separator: Text(""), content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text("") +
Expand All @@ -68,7 +68,7 @@ final class TextExtensionsTests: XCTestCase {
Text("") +
Text("amet, consectetur")
)
XCTAssertNoDifference(
expectNoDifference(
Text(separator: "", content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text(verbatim: "") +
Expand All @@ -81,7 +81,7 @@ final class TextExtensionsTests: XCTestCase {
}

func testInit_spaceSeparator() {
XCTAssertNoDifference(
expectNoDifference(
Text(separator: Text(" "), content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text(" ") +
Expand All @@ -91,7 +91,7 @@ final class TextExtensionsTests: XCTestCase {
Text(" ") +
Text("amet, consectetur")
)
XCTAssertNoDifference(
expectNoDifference(
Text(separator: " ", content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text(verbatim: " ") +
Expand All @@ -104,7 +104,7 @@ final class TextExtensionsTests: XCTestCase {
}

func testInit_newlineSeparator() {
XCTAssertNoDifference(
expectNoDifference(
Text(separator: Text("\n"), content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text("\n") +
Expand All @@ -114,7 +114,7 @@ final class TextExtensionsTests: XCTestCase {
Text("\n") +
Text("amet, consectetur")
)
XCTAssertNoDifference(
expectNoDifference(
Text(separator: "\n", content: textArrayBuilderText),
Text("Lorem").underline().foregroundColor(.blue) +
Text(verbatim: "\n") +
Expand Down
Loading