Files
denlvovich 2cf023e7b7 Various refactoring changes
commit_hash:13aed5d168f4743a61e7efd1979c44e726489a79
2025-09-05 01:02:40 +03:00

66 lines
1.6 KiB
Swift

@testable import LayoutKit
import VGSL
import XCTest
final class GalleryViewModelTests: XCTestCase {
func test_ItemsFilteredItemsList() {
let model = GalleryViewModel(
blocks: [
TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Item 1")
),
EmptyBlock.zeroSized,
TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Item 3")
),
],
metrics: GalleryViewMetrics(gaps: [10, 10]),
path: "model",
direction: .vertical
)
let expected = [
GalleryViewModel.Item(
crossAlignment: .leading,
content: TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Item 1")
)
),
GalleryViewModel.Item(
crossAlignment: .leading,
content: TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Item 3")
)
),
]
XCTAssertEqual(model.items, expected)
}
func test_RemovedItems() {
let model = GalleryViewModel(
blocks: [
EmptyBlock.zeroSized,
TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Item 1")
),
TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Item 3")
),
EmptyBlock.zeroSized,
],
metrics: GalleryViewMetrics(gaps: [10, 10]),
path: UIElementPath("model"),
direction: .vertical
)
XCTAssertEqual(model.removedItemsIndices, Set([0, 3]))
}
}