// NO LONGER ON COTTON (CIRCLE 2; SHELL DRAW 3): Comms says circle.list's `gone` words for a person, by number. // Every number and name is invented. import CottonKit @testable import CottonUI import Testing struct ChatCircleGoneTests { private func list(_ sections: [JSONValue]) -> JSONValue { .object(["sections": .array(sections)]) } private func row(_ number: String, _ state: String, _ detail: String) -> JSONValue { .object(["number": .string(number), "state": .string(state), "detail": .string(detail)]) } @Test func goneRowsAreReadByNumberInTheCoresWords() { let answer = list([ .object(["id": .string("people"), "rows": .array([row("+15550100001", "in", "Asha")])]), .object(["id": .string("gone"), "rows": .array([ row("+15550100002", "left", "Left Cotton"), row("+15550100003", "changed", "This number belongs to someone else on Cotton now"), ])]), ]) let gone = ChatCircleGone.of(answer) #expect(gone == ["+15550100002": "Left Cotton", "+15550100003": "This number belongs to someone else on Cotton now"]) #expect(gone[ChatCircleGone.key("+1 (555) 010-0002")] == "Left Cotton") } @Test func noGoneSectionReadsAsNobody() { #expect(ChatCircleGone.of(list([])).isEmpty) #expect(ChatCircleGone.of(.object(["unreachable": .string("Can't reach Cotton")])).isEmpty) } }