Initial commit: suixinkan_ios UIKit rewrite project.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-26 14:33:31 +08:00
commit 9edf993432
297 changed files with 47151 additions and 0 deletions

View File

@ -0,0 +1,60 @@
//
// ToastCenterTests.swift
// suixinkanTests
//
// Created by Codex on 2026/6/23.
//
import XCTest
@testable import suixinkan_ios
@MainActor
/// Toast
final class ToastCenterTests: XCTestCase {
/// show Toast
func testShowStoresMessage() {
let center = ToastCenter(autoDismissNanoseconds: 100_000_000)
center.show("保存成功")
XCTAssertEqual(center.snapshotForTests, ToastSnapshot(message: "保存成功"))
}
/// Toast
func testToastAutoDismissesAfterDelay() async throws {
let center = ToastCenter(autoDismissNanoseconds: 60_000_000)
center.show("保存成功")
try await Task.sleep(nanoseconds: 90_000_000)
XCTAssertEqual(center.snapshotForTests, ToastSnapshot(message: nil))
}
/// show
func testRepeatedShowResetsAutoDismissTimer() async throws {
let center = ToastCenter(autoDismissNanoseconds: 100_000_000)
center.show("第一条")
try await Task.sleep(nanoseconds: 70_000_000)
center.show("第二条")
try await Task.sleep(nanoseconds: 60_000_000)
XCTAssertEqual(center.snapshotForTests, ToastSnapshot(message: "第二条"))
try await Task.sleep(nanoseconds: 70_000_000)
XCTAssertEqual(center.snapshotForTests, ToastSnapshot(message: nil))
}
/// dismiss
func testDismissClearsMessageImmediately() async throws {
let center = ToastCenter(autoDismissNanoseconds: 100_000_000)
center.show("保存成功")
center.dismiss()
XCTAssertEqual(center.snapshotForTests, ToastSnapshot(message: nil))
try await Task.sleep(nanoseconds: 130_000_000)
XCTAssertEqual(center.snapshotForTests, ToastSnapshot(message: nil))
}
}