import XCTest @testable import LChatCore // The kind a new chat is created as (ThreadStore.createChat). The regression // this pins: an OPEN group with nobody but its creator — legitimate, since // others find it in Discover — used to fall through to kind:"self" and appear // as a second "Notes", its name and open_key dropped on the floor. Mirrors the // web's createThread(otherIds, {group}) in newchat.js, which sends // group ? "group" : "dm" and never derives "self" from an empty list. final class ThreadKindTests: XCTestCase { func testGroupIntentWinsOverAnEmptyMemberList() { XCTAssertEqual(ThreadStore.threadKind(others: [], group: true), "group") } func testNoOthersAndNoGroupIntentIsASelfThread() { XCTAssertEqual(ThreadStore.threadKind(others: [], group: false), "self") } func testOnePersonIsADMUnlessTheGroupFlowWasUsed() { XCTAssertEqual(ThreadStore.threadKind(others: ["u2"], group: false), "dm") XCTAssertEqual(ThreadStore.threadKind(others: ["u2"], group: true), "group") } func testTwoOrMoreOthersAreAlwaysAGroup() { XCTAssertEqual(ThreadStore.threadKind(others: ["u2", "u3"], group: false), "group") XCTAssertEqual(ThreadStore.threadKind(others: ["u2", "u3"], group: true), "group") } }