Implemented adding the room to the space after selection, and the editableSpace proxied API. Also updated and added tests.
This commit is contained in:
@@ -17100,6 +17100,70 @@ class SpaceServiceProxyMock: SpaceServiceProxyProtocol, @unchecked Sendable {
|
||||
return joinedParentsChildIDReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - editableSpaces
|
||||
|
||||
var editableSpacesUnderlyingCallsCount = 0
|
||||
var editableSpacesCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return editableSpacesUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = editableSpacesUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
editableSpacesUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
editableSpacesUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var editableSpacesCalled: Bool {
|
||||
return editableSpacesCallsCount > 0
|
||||
}
|
||||
|
||||
var editableSpacesUnderlyingReturnValue: [SpaceServiceRoomProtocol]!
|
||||
var editableSpacesReturnValue: [SpaceServiceRoomProtocol]! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return editableSpacesUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: [SpaceServiceRoomProtocol]? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = editableSpacesUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
editableSpacesUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
editableSpacesUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var editableSpacesClosure: (() async -> [SpaceServiceRoomProtocol])?
|
||||
|
||||
func editableSpaces() async -> [SpaceServiceRoomProtocol] {
|
||||
editableSpacesCallsCount += 1
|
||||
if let editableSpacesClosure = editableSpacesClosure {
|
||||
return await editableSpacesClosure()
|
||||
} else {
|
||||
return editableSpacesReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - addChild
|
||||
|
||||
var addChildToUnderlyingCallsCount = 0
|
||||
|
||||
@@ -111,6 +111,7 @@ extension [SpaceServiceRoomProtocol] {
|
||||
childrenCount: 1,
|
||||
joinedMembersCount: 500,
|
||||
canonicalAlias: "#the-foundation:matrix.org",
|
||||
joinRule: .private,
|
||||
state: .joined)),
|
||||
SpaceServiceRoomMock(.init(id: "space2",
|
||||
name: "The Second Foundation",
|
||||
|
||||
@@ -16,6 +16,7 @@ extension SpaceServiceProxyMock {
|
||||
var topLevelSpaces: [SpaceServiceRoomProtocol] = []
|
||||
var spaceFilters: [SpaceServiceFilter] = []
|
||||
var joinedParentSpaces: [SpaceServiceRoomProtocol] = []
|
||||
var editableSpaces: [SpaceServiceRoomProtocol] = []
|
||||
var spaceRoomLists: [String: SpaceRoomListProxyMock] = [:]
|
||||
var leaveSpaceRooms: [LeaveSpaceRoom] = []
|
||||
}
|
||||
@@ -27,6 +28,7 @@ extension SpaceServiceProxyMock {
|
||||
spaceFilterPublisher = .init(configuration.spaceFilters)
|
||||
|
||||
joinedParentsChildIDReturnValue = .success(configuration.joinedParentSpaces)
|
||||
editableSpacesReturnValue = configuration.editableSpaces
|
||||
spaceRoomListSpaceIDClosure = { spaceID in
|
||||
if let spaceRoomList = configuration.spaceRoomLists[spaceID] {
|
||||
.success(spaceRoomList)
|
||||
|
||||
Reference in New Issue
Block a user