1
0
mirror of git://jb55.com/damus synced 2024-09-19 19:46:51 +00:00
damus/damusTests/MarkdownTests.swift
2022-12-28 13:29:18 -08:00

44 lines
1.6 KiB
Swift

//
// MarkdownTests.swift
// damusTests
//
// Created by Lionello Lunesu on 2022-12-28.
//
import XCTest
@testable import damus
class MarkdownTests: XCTestCase {
let md_opts: AttributedString.MarkdownParsingOptions =
.init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func test_convert_link() throws {
let helper = Markdown()
let md = helper.process("prologue https://nostr.build epilogue")
let expected = try AttributedString(markdown: "prologue [https://nostr.build](https://nostr.build) epilogue", options: md_opts)
XCTAssertEqual(md, expected)
}
func test_convert_link_no_scheme() throws {
let helper = Markdown()
let md = helper.process("prologue damus.io epilogue")
let expected = try AttributedString(markdown: "prologue [damus.io](https://damus.io) epilogue", options: md_opts)
XCTAssertEqual(md, expected)
}
func test_convert_links() throws {
let helper = Markdown()
let md = helper.process("prologue damus.io https://nostr.build epilogue")
let expected = try AttributedString(markdown: "prologue [damus.io](https://damus.io) [https://nostr.build](https://nostr.build) epilogue", options: md_opts)
XCTAssertEqual(md, expected)
}
}