33 lines · 1.8 KB · SwiftRaw
import CottonValuesimport Foundationimport XCTestimport CottonKit@testable import CottonUIfinal class CalendarDefinitionTests: XCTestCase { private func eventDefinition() throws -> TableDefinition { let resources = try XCTUnwrap(Bundle(url: SourceSweep.iosSources.appendingPathComponent("CottonUI/Resources"))) return try XCTUnwrap(FixtureDefinitions.load(from: resources).definitions.first { $0.id == "event" }) } /// RULE: A guest list uses the same link face as one linked record, with every person's name retained. func testMultipleLinkedPeopleReadAsNames() throws { let column = ColumnDefinition(key: "people", type: .link, linkTo: "person") let value = RecordValue.list([.text("example-person-1"), .text("example-person-2")]) XCTAssertEqual(FaceText.linkIDs(value), ["example-person-1", "example-person-2"]) let line = try XCTUnwrap(FaceText.line(value, column: column, links: ["example-person-1": "Example guest", "example-person-2": "Example neighbour"])) XCTAssertTrue(line.contains("Example guest") && line.contains("Example neighbour"), line) } /// RULE: Declared word formats are rendered by the shared face, and a repeat rule reads as the core's words (`@column_words`), without exposing stored keys. func testWordAndRecurrenceFormats() throws { let reply = try XCTUnwrap(FaceText.line(.text("needs_action"), column: ColumnDefinition(key: "reply", type: .choice, format: .words))) XCTAssertFalse(reply.contains("_"), reply) let rule = FaceText.line(.text("FREQ=WEEKLY;INTERVAL=2"), words: ResolvedWords(said: "Every two weeks"), column: ColumnDefinition(key: "rrule", type: .text, format: .repeatRule)) XCTAssertEqual(rule, "Every two weeks") }}