import XCTest @testable import XuqmSDK final class SmokeTests: XCTestCase { func testSDKConfig() { let config = SDKConfig(appKey: "ak_test", debug: true, autoRegisterPush: false) XCTAssertEqual(config.appKey, "ak_test") XCTAssertTrue(config.debug) XCTAssertFalse(config.autoRegisterPush) XCTAssertEqual(config.appKey, "ak_test") } func testTokenStoreSaveGetClear() { let store = TokenStore() store.save("test_token_123") XCTAssertEqual(store.get(), "test_token_123") store.clear() XCTAssertNil(store.get()) } func testImMessageCoding() throws { let msg = ImMessage( id: "msg_1", appKey: "ak_test", fromUserId: "user_a", fromId: "user_a", toId: "user_b", chatType: .single, msgType: .text, content: "Hello", status: .sent, mentionedUserIds: nil, groupReadCount: nil, revoked: false, createdAt: 1714300000000, editedAt: nil ) let data = try JSONEncoder().encode(msg) let decoded = try JSONDecoder().decode(ImMessage.self, from: data) XCTAssertEqual(decoded.id, "msg_1") XCTAssertEqual(decoded.content, "Hello") XCTAssertEqual(decoded.status, .sent) } func testChatTypeAndMsgTypeRawValues() { XCTAssertEqual(ChatType.single.rawValue, "SINGLE") XCTAssertEqual(ChatType.group.rawValue, "GROUP") XCTAssertEqual(MsgType.text.rawValue, "TEXT") XCTAssertEqual(MsgType.revoked.rawValue, "REVOKED") } func testPageResultDecoding() throws { let json = """ { "content": [{"id": "1"}], "totalElements": 10, "totalPages": 1, "size": 20, "number": 0, "numberOfElements": 1, "first": true, "last": true, "empty": false } """.data(using: .utf8)! struct Item: Codable, Sendable { let id: String } let result = try JSONDecoder().decode(PageResult.self, from: json) XCTAssertEqual(result.content.count, 1) XCTAssertEqual(result.totalElements, 10) XCTAssertTrue(result.first) } func testApiResponseDecoding() throws { let json = """ { "code": 200, "status": "0", "data": {"token": "abc123"}, "message": "success" } """.data(using: .utf8)! struct TokenData: Decodable { let token: String } let response = try JSONDecoder().decode(ApiResponse.self, from: json) XCTAssertEqual(response.code, 200) XCTAssertEqual(response.data?.token, "abc123") } func testEmptyResponse() throws { let json = """ { "code": 200, "status": "0", "data": null, "message": "success" } """.data(using: .utf8)! let response = try JSONDecoder().decode(ApiResponse.self, from: json) XCTAssertEqual(response.code, 200) } }