Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 committed Oct 20, 2023
1 parent 43a97d4 commit bec8d87
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright 2023 The Matrix.org Foundation C.I.C
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,7 +30,8 @@ extension WysiwygComposerViewModelTests {

func testMentionsStatBySettingUserMention() {
viewModel.setMention(url: "https://matrix.to/#/@alice:matrix.org", name: "Alice", mentionType: .user)
XCTAssertEqual(viewModel.getMentionsState(), MentionsState(userIds: ["@alice:matrix.org"], roomIds: [], roomAliases: [], hasAtRoomMention: false))
XCTAssertEqual(viewModel.getMentionsState(),
MentionsState(userIds: ["@alice:matrix.org"], roomIds: [], roomAliases: [], hasAtRoomMention: false))
}

func testMentionsStateBySettingUserMentionFromContent() {
Expand All @@ -44,7 +45,8 @@ extension WysiwygComposerViewModelTests {

func testMentionsStatBySettingRoomAliasMention() {
viewModel.setMention(url: "https://matrix.to/#/#room:matrix.org", name: "Room", mentionType: .room)
XCTAssertEqual(viewModel.getMentionsState(), MentionsState(userIds: [], roomIds: [], roomAliases: ["#room:matrix.org"], hasAtRoomMention: false))
XCTAssertEqual(viewModel.getMentionsState(),
MentionsState(userIds: [], roomIds: [], roomAliases: ["#room:matrix.org"], hasAtRoomMention: false))
}

func testMentionsStateBySettingRoomAliasMentionFromContent() {
Expand Down Expand Up @@ -87,18 +89,35 @@ extension WysiwygComposerViewModelTests {
viewModel.setMention(url: "https://matrix.to/#/@alice:matrix.org", name: "Alice", mentionType: .user)
viewModel.setMention(url: "https://matrix.to/#/@alice:matrix.org", name: "Alice", mentionType: .user)

XCTAssertEqual(viewModel.getMentionsState(), MentionsState(userIds: ["@alice:matrix.org"], roomIds: [], roomAliases: [], hasAtRoomMention: false))
XCTAssertEqual(viewModel.getMentionsState(),
MentionsState(userIds: ["@alice:matrix.org"], roomIds: [], roomAliases: [], hasAtRoomMention: false))
}

func testMultipleMentionsBySettingThemWithContent() {
viewModel.setHtmlContent("<p><a href=\"https://matrix.to/#/@alice:matrix.org\">Alice</a>, <a href=\"https://matrix.to/#/!room:matrix.org\">Room</a>, <a href=\"https://matrix.to/#/@bob:matrix.org\">Bob</a>, <a href=\"https://matrix.to/#/#room:matrix.org\">Room</a>, @room</p>")
viewModel.setHtmlContent(
"""
<p><a href=\"https://matrix.to/#/@alice:matrix.org\">Alice</a>, \
<a href=\"https://matrix.to/#/!room:matrix.org\">Room</a>, \
<a href=\"https://matrix.to/#/@bob:matrix.org\">Bob</a>, \
<a href=\"https://matrix.to/#/#room:matrix.org\">Room</a>, \
@room</p>
"""
)
var mentionState = viewModel.getMentionsState()
XCTAssertEqual(Set(mentionState.userIds), ["@alice:matrix.org", "@bob:matrix.org"])
XCTAssertEqual(mentionState.roomAliases, ["#room:matrix.org"])
XCTAssertEqual(mentionState.roomIds, ["!room:matrix.org"])
XCTAssertTrue(mentionState.hasAtRoomMention)

viewModel.setMarkdownContent("[Room](https://matrix.to/#/!room:matrix.org), [Room](https://matrix.to/#/#room:matrix.org), [Alice](https://matrix.to/#/@alice:matrix.org), [Bob](https://matrix.to/#/@bob:matrix.org), @room")
viewModel.setMarkdownContent(
"""
[Room](https://matrix.to/#/!room:matrix.org), \
[Room](https://matrix.to/#/#room:matrix.org), \
[Alice](https://matrix.to/#/@alice:matrix.org), \
[Bob](https://matrix.to/#/@bob:matrix.org), \
@room
"""
)
mentionState = viewModel.getMentionsState()
XCTAssertEqual(Set(mentionState.userIds), ["@alice:matrix.org", "@bob:matrix.org"])
XCTAssertEqual(mentionState.roomAliases, ["#room:matrix.org"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ extension WysiwygComposerViewModelTests {
)
}


func testAtMentionWithNoSuggestionAtLeading() {
_ = viewModel.replaceText(range: .zero, replacementText: "Text")
viewModel.select(range: .init(location: 0, length: 0))
Expand Down

0 comments on commit bec8d87

Please sign in to comment.