mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-08 06:56:10 +00:00
test: cover message quote formatting and draft append behavior
Pinned multiline quotes, system-sender omission, and non-destructive append.
This commit is contained in:
parent
3152eeb139
commit
6103e3f4e5
37
bitchatTests/Services/MessageClipboardTests.swift
Normal file
37
bitchatTests/Services/MessageClipboardTests.swift
Normal file
@ -0,0 +1,37 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import bitchat
|
||||
|
||||
struct MessageClipboardTests {
|
||||
@Test func quoteWrapsEachLineAndAddsSender() {
|
||||
let quoted = MessageClipboard.quoteForComposer("hello\nworld", sender: "alice")
|
||||
#expect(quoted == "> @alice:\n> hello\n> world\n\n")
|
||||
}
|
||||
|
||||
@Test func quoteSkipsSystemSenderHeader() {
|
||||
let quoted = MessageClipboard.quoteForComposer("joined", sender: "system")
|
||||
#expect(quoted == "> joined\n\n")
|
||||
}
|
||||
|
||||
@Test func emptyContentYieldsEmptyQuote() {
|
||||
#expect(MessageClipboard.quoteForComposer(" ", sender: "alice").isEmpty)
|
||||
}
|
||||
|
||||
@Test func appendQuotePreservesExistingDraft() {
|
||||
let result = MessageClipboard.appendQuote(
|
||||
to: "already typing",
|
||||
content: "prior message",
|
||||
sender: "bob"
|
||||
)
|
||||
#expect(result == "already typing\n> @bob:\n> prior message\n\n")
|
||||
}
|
||||
|
||||
@Test func appendQuoteOntoEmptyDraft() {
|
||||
let result = MessageClipboard.appendQuote(
|
||||
to: "",
|
||||
content: "solo",
|
||||
sender: "carol"
|
||||
)
|
||||
#expect(result == "> @carol:\n> solo\n\n")
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user