Files
pkurchatov 27a3472171 Enabled blankLinesBetweenImports swiftformat rule
commit_hash:84ea24cbdf21ef89741080f38ec5e583172a2458
2024-12-20 12:41:02 +03:00

51 lines
1.4 KiB
Swift

import LayoutKit
import VGSL
import XCTest
final class GenericViewBlockTests: XCTestCase {
func test_WhenSameContentViewSetForAnotherBlock_ContentIsUpdatedForLastBlock() throws {
let contentView = UIView()
let block = makeBlock(.view(contentView))
let view1 = GenericViewBlock.makeBlockView()
let view2 = GenericViewBlock.makeBlockView()
block.configure(view1)
block.configure(view2)
block.configure(view1)
XCTAssertIdentical(contentView.superview, view1)
XCTAssertTrue(view2.subviews.isEmpty)
}
func test_WhenSameContentLayerSetForAnotherBlock_ContentIsUpdatedForLastBlock() throws {
let contentLayer = CALayer()
let block = makeBlock(.layer(contentLayer))
let view1 = GenericViewBlock.makeBlockView()
let view2 = GenericViewBlock.makeBlockView()
block.configure(view1)
block.configure(view2)
block.configure(view1)
XCTAssertIdentical(contentLayer.superlayer, view1.layer)
XCTAssertNil(view2.layer.sublayers)
}
}
private func makeBlock(_ content: GenericViewBlock.Content) -> GenericViewBlock {
GenericViewBlock(content: content, width: .resizable, height: .resizable)
}
extension GenericViewBlock {
fileprivate func configure(_ view: UIView & BlockViewProtocol) {
configureBlockView(
view,
observer: nil,
overscrollDelegate: nil,
renderingDelegate: nil
)
}
}