eleven / ocho Public

Clone
git clone https://amadan.net/eleven/ocho

Plain git — no account needed to clone.

Download

Download this file

1import XCTest
2@testable import LChatCore
3
4// The kind a new chat is created as (ThreadStore.createChat). The regression
5// this pins: an OPEN group with nobody but its creator — legitimate, since
6// others find it in Discover — used to fall through to kind:"self" and appear
7// as a second "Notes", its name and open_key dropped on the floor. Mirrors the
8// web's createThread(otherIds, {group}) in newchat.js, which sends
9// group ? "group" : "dm" and never derives "self" from an empty list.
10final class ThreadKindTests: XCTestCase {
11 func testGroupIntentWinsOverAnEmptyMemberList() {
12 XCTAssertEqual(ThreadStore.threadKind(others: [], group: true), "group")
13 }
14
15 func testNoOthersAndNoGroupIntentIsASelfThread() {
16 XCTAssertEqual(ThreadStore.threadKind(others: [], group: false), "self")
17 }
18
19 func testOnePersonIsADMUnlessTheGroupFlowWasUsed() {
20 XCTAssertEqual(ThreadStore.threadKind(others: ["u2"], group: false), "dm")
21 XCTAssertEqual(ThreadStore.threadKind(others: ["u2"], group: true), "group")
22 }
23
24 func testTwoOrMoreOthersAreAlwaysAGroup() {
25 XCTAssertEqual(ThreadStore.threadKind(others: ["u2", "u3"], group: false), "group")
26 XCTAssertEqual(ThreadStore.threadKind(others: ["u2", "u3"], group: true), "group")
27 }
28}
29