diff --git a/Tests/CollectionViewTests/ViewConfiguratorTests.swift b/Tests/CollectionViewTests/ViewConfiguratorTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..df2e993b0f70bceefc124cca9fda9c3be5723db6 --- /dev/null +++ b/Tests/CollectionViewTests/ViewConfiguratorTests.swift @@ -0,0 +1,33 @@ +import CustomDump +import XCTest +@testable import CollectionView + +// MARK: - Example view configurator: + +private class ProfileView: UIView { + let username = UILabel() +} + +private struct User { + var name: String +} + +private extension ViewConfigurator where View == ProfileView, Model == User { + static let profileViewUserConfigurator = ViewConfigurator { view, model in + view.username.text = model.name + } +} + +// MARK: - Tests: + +final class ViewConfiguratorTests: XCTestCase { + func testExampleConfigurator() { + let profileView = ProfileView() + let user = User(name: "John") + + let configure = ViewConfigurator.profileViewUserConfigurator + configure(profileView, with: user) + + XCTAssertNoDifference(profileView.username.text, user.name) + } +}