Cotton code
50 lines · 2.4 KB · SwiftRaw
import CottonPaper// A Markdown column's page is set, never typed with its marks: a meeting's// summary reads as formatted text on its card (owner, 23 Oct 2026).import CottonValuesimport XCTest@testable import CottonFaces@testable import CottonUIfinal class FaceMarkdownTests: XCTestCase {    private func plain(_ text: String) -> String { String(FaceMarkdown.set(text, theme: .paper).characters) }    func testNoMarkIsTyped() {        XCTAssertEqual(plain("## Decisions"), "Decisions")        XCTAssertEqual(plain("- Ship on **Friday**"), "\u{2022} Ship on Friday")        XCTAssertEqual(plain("* [x] Ravi owns the importer"), "☑ Ravi owns the importer")        XCTAssertEqual(plain("> Closes early"), "Closes early")        XCTAssertEqual(plain("---"), "")        XCTAssertEqual(plain("Use `cargo` and _care_"), "Use cargo and care")    }    func testLinesStayLines() {        XCTAssertEqual(plain("# Shelf\nShips **Friday**.\n\n- one\n- two"), "Shelf\nShips Friday.\n\n\u{2022} one\n\u{2022} two")    }    func testAHeadingIsStrongAndAQuoteIsEmphasised() {        let heading = FaceMarkdown.line("## Decisions", theme: .paper)        XCTAssertEqual(heading.runs.first?.inlinePresentationIntent, .stronglyEmphasized)        let quote = FaceMarkdown.line("> Closes early", theme: .paper)        XCTAssertEqual(quote.runs.first?.inlinePresentationIntent, .emphasized)    }    func testAPageKnowsItsColumnKeepsMarkdown() throws {        let json = """        {"id":"meeting","name":"Meeting","plural":"Meetings","builtin":false,         "columns":[{"key":"title","name":"Title","type":"text"},                    {"key":"summary","name":"What was said","type":"longtext","markdown":true},                    {"key":"notes","name":"Notes","type":"longtext"}],         "title":"title","date":null,"project":null,"order":null,         "slip":{"title":"title"},"tile":{"face":"slip-list"},"page":[],         "card":{"face":"audio","fields":[{"slot":"title","column":"title"}],"pages":["summary","notes"]},         "tables":[]}        """        let definition = try JSONDecoder().decode(TableDefinition.self, from: Data(json.utf8))        let pages = DeckCardFill.pages(definition, record: TableRecord(id: "m", values: [            "summary": .text("## Shelf"), "notes": .text("Plain words."),        ]))        XCTAssertEqual(pages.map(\.markdown), [true, false])    }}