Files
e-party-iOS/yanaAPITests/yanaAPITests.swift
edwinQQQ a0200c8859 feat: 添加项目基础文件和依赖管理
新增.gitignore、Podfile和Podfile.lock文件以管理项目依赖,添加README.md文件提供项目简介和安装步骤,创建NIMSessionManager、ClientConfig、LogManager和NetworkManager等管理类以支持网络请求和日志记录功能,更新AppDelegate和ContentView以集成NIM SDK和实现用户登录功能。
2025-05-29 16:14:28 +08:00

69 lines
2.3 KiB
Swift

//
// yanaAPITests.swift
// yanaAPITests
//
// Created by P on 2025/5/27.
//
import XCTest
@testable import yana
final class yanaAPITests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}
func testPerformanceExample() throws {
// This is an example of a performance test case.
measure {
// Put the code you want to measure the time of here.
}
}
func testClientInit_Success() {
let expectation = self.expectation(description: "clientInit success")
API.clientInit { result in
switch result {
case .success(let data):
XCTAssertNotNil(data)
//
case .failure(let error):
XCTFail("Expected success, got error: \(error)")
}
expectation.fulfill()
}
waitForExpectations(timeout: 5, handler: nil)
}
func testClientInit_Failure() {
// mock
//
let expectation = self.expectation(description: "clientInit failure")
// APIbaseURLmock
API.clientInit { result in
switch result {
case .success(_):
// fail
XCTFail("Expected failure, got success")
case .failure(let error):
XCTAssertNotNil(error)
}
expectation.fulfill()
}
waitForExpectations(timeout: 5, handler: nil)
}
}