mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
27a3472171
commit_hash:84ea24cbdf21ef89741080f38ec5e583172a2458
51 lines
1.4 KiB
Swift
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
|
|
)
|
|
}
|
|
}
|