Files
divkit/client/ios/DivKitTests/Extensions/DivImageExtensionsTests.swift
T
2022-09-07 19:33:26 +03:00

49 lines
1.2 KiB
Swift

@testable import DivKit
@testable import LayoutKit
import XCTest
final class DivImageExtensionsTests: XCTestCase {
func test_WhenDivHasAction_CreatesBlockWithIt() throws {
let block = try makeBlock(fromFile: "with_action") as? DecoratingBlock
XCTAssertEqual(block?.actions, Expected.actions)
}
func test_WhenDivHasSetStateAction_CreatesBlockWithIt() throws {
let block = try makeBlock(
fromFile: "with_set_state_action"
) as? DecoratingBlock
XCTAssertEqual(block?.actions, Expected.setStateActions)
}
func test_WhenWidthIsWrapContent_ThrowsError() {
XCTAssertThrowsError(
try makeBlock(fromFile: "width_wrap_content"),
DivBlockModelingError(
"DivImage has wrap_content width",
path: .root
)
)
}
func test_WhenHeightIsWrapContent_ThrowsError() throws {
XCTAssertThrowsError(
try makeBlock(fromFile: "height_wrap_content"),
DivBlockModelingError(
"DivImage without aspect has wrap_content height",
path: .root
)
)
}
}
private func makeBlock(fromFile filename: String) throws -> Block {
try DivImageTemplate.make(
fromFile: filename,
subdirectory: "div-image",
context: .default
)
}