Files
Luma/Tests/ChatScrollPositionPolicyTests.swift
2026-07-30 20:07:51 +07:00

30 lines
1.0 KiB
Swift

import XCTest
@testable import Luma
final class ChatScrollPositionPolicyTests: XCTestCase {
func testBottomSentinelCrossesOnlyTheTelegramButtonThreshold() {
XCTAssertTrue(ChatScrollPositionPolicy.isNearBottom(
bottomY: 796,
viewportHeight: 700
))
XCTAssertFalse(ChatScrollPositionPolicy.isNearBottom(
bottomY: 797,
viewportHeight: 700
))
}
func testInvalidFirstLayoutDoesNotFlashTheButton() {
XCTAssertTrue(ChatScrollPositionPolicy.isNearBottom(
bottomY: 0,
viewportHeight: 0
))
}
func testNativeScrollDistanceCanHideAndRestoreButtonRepeatedly() {
XCTAssertFalse(ChatScrollPositionPolicy.isNearBottom(distanceFromBottom: 180))
XCTAssertTrue(ChatScrollPositionPolicy.isNearBottom(distanceFromBottom: 0))
XCTAssertFalse(ChatScrollPositionPolicy.isNearBottom(distanceFromBottom: 220))
XCTAssertTrue(ChatScrollPositionPolicy.isNearBottom(distanceFromBottom: -12))
}
}