mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Swift Testing for Unit Tests PART 1 (#5119)
* migrated a lot of unit tests to Swift Testing and added a new implementation for deferred fulfillment more tests migration Cleaned the code manually to establish some good patterns more code improvements some more code improvements removed empty tests update project * more pr suggestions and cleanups * removed the TestSetup pattern * fixing claude not reusing tests * pr suggestion + added indent rule to swiftformat so that we can prevent AIs to change that
This commit is contained in:
@@ -8,11 +8,13 @@
|
||||
|
||||
@testable import ElementX
|
||||
import MatrixRustSDK
|
||||
import XCTest
|
||||
import Testing
|
||||
|
||||
@MainActor
|
||||
class TimelineItemFactoryTests: XCTestCase {
|
||||
func testCallInvite() {
|
||||
@Suite
|
||||
struct TimelineItemFactoryTests {
|
||||
@Test
|
||||
func callInvite() throws {
|
||||
let ownUserID = "@alice:matrix.org"
|
||||
let senderUserID = "@bob:matrix.org"
|
||||
|
||||
@@ -23,20 +25,16 @@ class TimelineItemFactoryTests: XCTestCase {
|
||||
let eventTimelineItem = EventTimelineItem.mockCallInvite(sender: senderUserID)
|
||||
|
||||
let eventTimelineItemProxy = EventTimelineItemProxy(item: eventTimelineItem, uniqueID: .init("0"))
|
||||
|
||||
let item = try #require(factory.buildTimelineItem(for: eventTimelineItemProxy, isDM: false) as? CallInviteRoomTimelineItem,
|
||||
"Incorrect item type")
|
||||
|
||||
let item = factory.buildTimelineItem(for: eventTimelineItemProxy, isDM: false)
|
||||
|
||||
guard let item = item as? CallInviteRoomTimelineItem else {
|
||||
XCTFail("Incorrect item type")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(item.isReactable, false)
|
||||
XCTAssertEqual(item.canBeRepliedTo, false)
|
||||
XCTAssertEqual(item.isEditable, false)
|
||||
XCTAssertEqual(item.sender, TimelineItemSender(id: senderUserID))
|
||||
XCTAssertEqual(item.properties.isEdited, false)
|
||||
XCTAssertEqual(item.properties.reactions, [])
|
||||
XCTAssertEqual(item.properties.deliveryStatus, nil)
|
||||
#expect(item.isReactable == false)
|
||||
#expect(item.canBeRepliedTo == false)
|
||||
#expect(item.isEditable == false)
|
||||
#expect(item.sender == TimelineItemSender(id: senderUserID))
|
||||
#expect(item.properties.isEdited == false)
|
||||
#expect(item.properties.reactions == [])
|
||||
#expect(item.properties.deliveryStatus == nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user