mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
2cf023e7b7
commit_hash:13aed5d168f4743a61e7efd1979c44e726489a79
66 lines
1.6 KiB
Swift
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]))
|
|
}
|
|
}
|