Cotton code
33 lines · 1.7 KB · SwiftRaw
// THE CIRCLE and THE ONE SHARE SHEET on iPhone (CONTACTS-ANSWERS 9, 10): an act is read as the core gives it, and a// person is picked by contact id, else number. Every name and number is invented.import CottonKit@testable import CottonUIimport Testingstruct CircleShareTests {    private func call(_ method: String, _ request: JSONValue) -> JSONValue { .object(["method": .string(method), "request": request]) }    @Test func anActCarriesItsWordsItsMethodAndItsConfirm() {        let block = CoreAct(.object([            "id": .string("block"), "words": .string("Block"), "red": .bool(true), "confirm": .string("Block Ravi?"),            "call": call("circle.answer", .object(["ask": .string("+15550100002"), "answer": .string("block")])),        ]))        #expect(block?.id == "block")        #expect(block?.method == "circle.answer")        #expect(block?.red == true && block?.primary == false)        #expect(block?.confirm == "Block Ravi?")        #expect(block?.request["answer"]?.string == "block")    }    @Test func anActWithoutWordsOrACallIsNotDrawn() {        #expect(CoreAct(.object(["id": .string("x"), "call": call("circle.remove", .object([:]))])) == nil)        #expect(CoreAct(.object(["id": .string("x"), "words": .string("Remove")])) == nil)        #expect(CoreAct.all(.array([.object(["words": .string("Ask"), "call": call("circle.ask", .object([:]))]), .null])).count == 1)    }    @Test func aPersonIsPickedByContactElseNumber() {        #expect(ShareSheetModel.key(.object(["person": .string("p-1"), "number": .string("+15550100001")])) == "p-1")        #expect(ShareSheetModel.key(.object(["person": .null, "number": .string("+15550100001")])) == "+15550100001")    }}