IceCubes/Packages/Timeline/Tests/TimelineTests/TimelineViewModelTests.swift
2023-12-30 09:08:19 +01:00

25 lines
741 B
Swift

@testable import Timeline
import XCTest
import Network
import Models
@MainActor
final class TimelineViewModelTests: XCTestCase {
func testStreamEventInsertNewStatus() async throws {
let subject = TimelineViewModel()
let client = Client(server: "localhost")
subject.client = client
subject.timeline = .home
subject.isTimelineVisible = true
let isEmpty = await subject.datasource.isEmpty
XCTAssertTrue(isEmpty)
await subject.datasource.append(.placeholder())
var count = await subject.datasource.count()
XCTAssertTrue(count == 1)
await subject.handleEvent(event: StreamEventUpdate(status: .placeholder()))
count = await subject.datasource.count()
XCTAssertTrue(count == 2)
}
}