- move backend/, clients/, scripts/ to DELETE/ (v0.1 era, replaced by on-device arch) - delete feature/v0.1-backend-and-macos branch - add TaskStore dependency to project.yml - fix ComposeViewModel deinit concurrency, make toMessageSummary public - regenerate Xcode project, verify macOS build succeeds Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
1.3 KiB
Swift
56 lines
1.3 KiB
Swift
import Testing
|
|
@testable import MagnumOpus
|
|
|
|
@Suite("APIClient")
|
|
struct APIClientTests {
|
|
@Test("decodes thread list from JSON")
|
|
func decodesThreadList() throws {
|
|
let json = """
|
|
{
|
|
"threads": [
|
|
{
|
|
"threadId": "t001",
|
|
"subject": "Q1 Planning",
|
|
"authors": "Alice, Bob",
|
|
"totalMessages": 3,
|
|
"tags": "inbox,unread",
|
|
"timestamp": 1709884532,
|
|
"accountId": "personal"
|
|
}
|
|
]
|
|
}
|
|
""".data(using: .utf8)!
|
|
|
|
let response = try JSONDecoder().decode(ThreadListResponse.self, from: json)
|
|
#expect(response.threads.count == 1)
|
|
#expect(response.threads[0].subject == "Q1 Planning")
|
|
}
|
|
|
|
@Test("decodes message list from JSON")
|
|
func decodesMessageList() throws {
|
|
let json = """
|
|
{
|
|
"messages": [
|
|
{
|
|
"messageId": "msg001@example.com",
|
|
"threadId": "t001",
|
|
"fromHeader": "Alice <alice@example.com>",
|
|
"toHeader": "user@example.com",
|
|
"subject": "Q1 Planning",
|
|
"date": "2024-03-08T10:15:32+01:00",
|
|
"inReplyTo": "",
|
|
"body": "Hey, let's plan Q1.",
|
|
"tags": "inbox,unread",
|
|
"timestamp": 1709884532,
|
|
"accountId": "personal"
|
|
}
|
|
]
|
|
}
|
|
""".data(using: .utf8)!
|
|
|
|
let response = try JSONDecoder().decode(MessageListResponse.self, from: json)
|
|
#expect(response.messages.count == 1)
|
|
#expect(response.messages[0].body == "Hey, let's plan Q1.")
|
|
}
|
|
}
|