Cotton code
31 lines · 1.5 KB · SwiftRaw
// The shared pieces' definition keys and their reading: the cover's footer,// the archive, read-only columns and records, a place's map picture, the// slip's forms and the cover-grid tile (rebuild note 7b95efa4, the shared// format's 23:10 and 00:25 additions). Every record is invented.import CottonValuesimport Foundationimport XCTest@testable import CottonUI@MainActorfinal class SharedFaceKeysTests: XCTestCase {    private func decode(_ extra: String, slip: String = "", columns: String = "") throws -> TableDefinition {        try TableDefinition.decode(Data("""            {"id":"example","name":"Example","plural":"Examples","builtin":false,             "columns":[{"key":"title","type":"text"},{"key":"site","type":"text"},{"key":"kind","type":"choice","choices":["essay","news"]},                        {"key":"lat","type":"number","pair":"lng"},{"key":"lng","type":"number"},                        {"key":"archived_at","type":"date"},{"key":"managed_by","type":"text"},                        {"key":"made_at","type":"date","readonly":true}\(columns)],             "title":"title","slip":{"title":"title","subtitle":"site"\(slip)},"tile":{"face":"slip-list"},             "page":[{"heading":null,"columns":["title"]}]\(extra)}            """.utf8))    }    private func record(_ values: [String: RecordValue]) -> TableRecord {        TableRecord(id: "example-record-1", values: ["title": .text("An example record")].merging(values) { $1 })    }}