a
b
"), NSAttributedString(string: "a\n\nb", attributes: [ .font: font, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -86,10 +93,12 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("hello"), NSAttributedString(string: "hello", attributes: [ .font: italicFont, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) XCTAssertEqual(convert("hello"), NSAttributedString(string: "hello", attributes: [ .font: italicFont, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -97,10 +106,12 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("hello"), NSAttributedString(string: "hello", attributes: [ .font: boldFont, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) XCTAssertEqual(convert("hello"), NSAttributedString(string: "hello", attributes: [ .font: boldFont, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -108,6 +119,7 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("hello"), NSAttributedString(string: "hello", attributes: [ .font: boldItalicFont, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -123,21 +135,21 @@ final class AttributedStringConverterTests: XCTestCase { .font: italicFont, ])) result.addAttribute(.paragraphStyle, value: NSParagraphStyle.default, range: NSRange(location: 0, length: result.length)) + result.addAttribute(.foregroundColor, value: color, range: NSRange(location: 0, length: result.length)) XCTAssertEqual(convert("bold both italic"), result) } func testMisnestedLink() { let result = NSMutableAttributedString() result.append(NSAttributedString(string: "hello ", attributes: [ - .link: URL(string: "https://example.com")!, .font: font, - .paragraphStyle: NSParagraphStyle.default, ])) result.append(NSAttributedString(string: "world", attributes: [ - .link: URL(string: "https://example.com")!, .font: boldFont, - .paragraphStyle: NSParagraphStyle.default, ])) + result.addAttribute(.link, value: URL(string: "https://example.com")!, range: NSRange(location: 0, length: result.length)) + result.addAttribute(.paragraphStyle, value: NSParagraphStyle.default, range: NSRange(location: 0, length: result.length)) + result.addAttribute(.foregroundColor, value: color, range: NSRange(location: 0, length: result.length)) XCTAssertEqual(convert("hello world"), result) } @@ -145,6 +157,7 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("wee
"), NSAttributedString(string: "wee", attributes: [
.font: monospaceFont,
.paragraphStyle: NSParagraphStyle.default,
+ .foregroundColor: color,
]))
}
@@ -160,6 +174,7 @@ final class AttributedStringConverterTests: XCTestCase {
XCTAssertEqual(convert("wee"), NSAttributedString(string: "wee", attributes: [ .font: monospaceFont, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -167,10 +182,12 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("
hello"), NSAttributedString(string: "hello", attributes: [ .font: italicFont, .paragraphStyle: blockquoteParagraphStyle, + .foregroundColor: color, ])) XCTAssertEqual(convert("
hello"), NSAttributedString(string: "hello", attributes: [ .font: boldItalicFont, .paragraphStyle: blockquoteParagraphStyle, + .foregroundColor: color, ])) } @@ -184,6 +201,7 @@ final class AttributedStringConverterTests: XCTestCase { .font: font, .paragraphStyle: NSParagraphStyle.default, ])) + result.addAttribute(.foregroundColor, value: color, range: NSRange(location: 0, length: result.length)) XCTAssertEqual(convert("
weeafter"), result) } @@ -201,6 +219,7 @@ final class AttributedStringConverterTests: XCTestCase { .font: italicFont, .paragraphStyle: blockquoteParagraphStyle, ])) + result.addAttribute(.foregroundColor, value: color, range: NSRange(location: 0, length: result.length)) XCTAssertEqual(convert("
a
b"), result) } @@ -208,6 +227,7 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("asdf"), NSAttributedString(string: "asdf", attributes: [ .font: font, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -222,6 +242,7 @@ final class AttributedStringConverterTests: XCTestCase { .font: font, .paragraphStyle: NSParagraphStyle.default, .link: URL(string: "https://apple.com")!, + .foregroundColor: color, ])) } @@ -248,6 +269,7 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(replaced, NSAttributedString(string: "…", attributes: [ .font: font, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) } @@ -256,6 +278,7 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(result, NSAttributedString(string: "\t1.\ta\n\t2.\tb", attributes: [ .font: font, .paragraphStyle: listParagraphStyle, + .foregroundColor: color, ])) } @@ -263,6 +286,7 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("🇺🇸"), NSAttributedString(string: "🇺🇸", attributes: [ .font: font, .paragraphStyle: NSParagraphStyle.default, + .foregroundColor: color, ])) }