mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Re-enable unit tests and fix a few lint warnings
This commit is contained in:
parent
1e98305012
commit
46f191c33b
6 changed files with 23 additions and 24 deletions
|
@ -65,7 +65,7 @@ extension MockCompletionSuggestionScreenState: CommandsProviderProtocol {
|
|||
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
||||
commands([
|
||||
CommandsProviderCommand(name: "/ban",
|
||||
parametersFormat: "<user-id> [reason]",
|
||||
parametersFormat: "<user-id> [<reason>]",
|
||||
description: "Bans user with given id"),
|
||||
CommandsProviderCommand(name: "/invite",
|
||||
parametersFormat: "<user-id>",
|
||||
|
|
|
@ -29,7 +29,7 @@ class CompletionSuggestionViewModel: CompletionSuggestionViewModelType, Completi
|
|||
// MARK: Public
|
||||
|
||||
var sharedContext: CompletionSuggestionViewModelType.Context {
|
||||
return self.context
|
||||
context
|
||||
}
|
||||
|
||||
var completion: ((CompletionSuggestionViewModelResult) -> Void)?
|
||||
|
|
|
@ -103,8 +103,7 @@ final class CompletionSuggestionCoordinator: Coordinator, Presentable {
|
|||
|
||||
completionSuggestionService.items.sink { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.delegate?.completionSuggestionCoordinator(self,
|
||||
didUpdateViewHeight: self.calculateViewHeight())
|
||||
self.delegate?.completionSuggestionCoordinator(self, didUpdateViewHeight: self.calculateViewHeight())
|
||||
}.store(in: &cancellables)
|
||||
}
|
||||
|
||||
|
@ -233,11 +232,7 @@ private class CompletionSuggestionCoordinatorCommandProvider: CommandsProviderPr
|
|||
}
|
||||
|
||||
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
||||
commands(self.commands.map { CommandsProviderCommand(
|
||||
name: $0.cmd,
|
||||
parametersFormat: $0.parametersFormat,
|
||||
description: $0.description
|
||||
)})
|
||||
commands(self.commands.map { CommandsProviderCommand(name: $0.cmd, parametersFormat: $0.parametersFormat, description: $0.description) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,14 +200,14 @@ private struct TextTrigger: Equatable {
|
|||
let text: String
|
||||
|
||||
func asString() -> String {
|
||||
return String(key.rawValue) + text
|
||||
String(key.rawValue) + text
|
||||
}
|
||||
}
|
||||
|
||||
private extension String {
|
||||
// Returns current completion suggestion for a text message, if any.
|
||||
var currentTextTrigger: TextTrigger? {
|
||||
let components = self.components(separatedBy: .whitespaces)
|
||||
let components = components(separatedBy: .whitespaces)
|
||||
guard var lastComponent = components.last,
|
||||
lastComponent.count > 0,
|
||||
let suggestionKey = SuggestionKey(rawValue: lastComponent.removeFirst()),
|
||||
|
|
|
@ -143,11 +143,20 @@ extension CompletionSuggestionServiceTests: RoomMembersProviderProtocol {
|
|||
|
||||
extension CompletionSuggestionServiceTests: CommandsProviderProtocol {
|
||||
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
||||
let commandList = ["/ban", "/invite", "/join", "/me"]
|
||||
|
||||
commands(commandList.map { command in
|
||||
CommandsProviderCommand(name: command)
|
||||
})
|
||||
commands([
|
||||
CommandsProviderCommand(name: "/ban",
|
||||
parametersFormat: "<user-id> [<reason>]",
|
||||
description: "Bans user with given id"),
|
||||
CommandsProviderCommand(name: "/invite",
|
||||
parametersFormat: "<user-id>",
|
||||
description: "Invites user with given id to current room"),
|
||||
CommandsProviderCommand(name: "/join",
|
||||
parametersFormat: "<room-address>",
|
||||
description: "Joins room with given address"),
|
||||
CommandsProviderCommand(name: "/me",
|
||||
parametersFormat: "<message>",
|
||||
description: "Displays action")
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ struct CompletionSuggestionList: View {
|
|||
to the list items in order to be as close as possible as the
|
||||
`UITableView` display.
|
||||
*/
|
||||
@available (iOS 16.0, *)
|
||||
@available(iOS 16.0, *)
|
||||
static let collectionViewPaddingCorrection: CGFloat = -5.0
|
||||
}
|
||||
|
||||
|
@ -44,19 +44,14 @@ struct CompletionSuggestionList: View {
|
|||
// MARK: Public
|
||||
|
||||
@ObservedObject var viewModel: CompletionSuggestionViewModel.Context
|
||||
var showBackgroundShadow: Bool = true
|
||||
var showBackgroundShadow = true
|
||||
|
||||
var body: some View {
|
||||
if viewModel.viewState.items.isEmpty {
|
||||
EmptyView()
|
||||
} else {
|
||||
ZStack {
|
||||
CompletionSuggestionListItem(content: CompletionSuggestionViewStateItem.user(
|
||||
id: "Prototype",
|
||||
avatar: AvatarInput(mxContentUri: "",
|
||||
matrixItemId: "",
|
||||
displayName: "Prototype"),
|
||||
displayName: "Prototype"))
|
||||
CompletionSuggestionListItem(content: CompletionSuggestionViewStateItem.user(id: "Prototype", avatar: AvatarInput(mxContentUri: "", matrixItemId: "", displayName: "Prototype"), displayName: "Prototype"))
|
||||
.background(ViewFrameReader(frame: $prototypeListItemFrame))
|
||||
.hidden()
|
||||
if showBackgroundShadow {
|
||||
|
|
Loading…
Reference in a new issue