add NSE sources to EX project to easily implement mocking and allow the code to be unit tested
This commit is contained in:
39
UnitTests/Sources/NotificationContentBuilderTests.swift
Normal file
39
UnitTests/Sources/NotificationContentBuilderTests.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Copyright 2025 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import MatrixRustSDK
|
||||
import XCTest
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
final class NotificationContentBuilderTests: XCTestCase {
|
||||
var notificationContentBuilder: NotificationContentBuilder!
|
||||
var mediaProvider: MediaProviderMock!
|
||||
|
||||
override func setUp() {
|
||||
let stringBuilder = RoomMessageEventStringBuilder(attributedStringBuilder: AttributedStringBuilder(mentionBuilder: PlainMentionBuilder()),
|
||||
destination: .notification)
|
||||
mediaProvider = MediaProviderMock(configuration: .init())
|
||||
notificationContentBuilder = NotificationContentBuilder(messageEventStringBuilder: stringBuilder,
|
||||
userSession: NSEUserSessionMock(.init()))
|
||||
}
|
||||
|
||||
func testDMMessageNotification() async {
|
||||
let notificationItem = NotificationItemProxyMock(.init(senderDisplayName: "Alice",
|
||||
roomDisplayName: "Alice",
|
||||
roomJoinedMembers: 2,
|
||||
isRoomDirect: true,
|
||||
isRoomPrivate: true))
|
||||
var notificationContent = UNMutableNotificationContent()
|
||||
await notificationContentBuilder.process(notificationContent: ¬ificationContent,
|
||||
notificationItem: notificationItem,
|
||||
mediaProvider: mediaProvider)
|
||||
|
||||
XCTAssertEqual(notificationContent.title, "Alice")
|
||||
XCTAssertEqual(notificationContent.body, "Hello world!")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user