From 4484d8011e00eb61ded48c5201186987ef82a31c Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Mon, 18 Jul 2022 14:08:56 +0100 Subject: [PATCH] Add example and tests for ViewConfigurator --- .../ViewConfiguratorTests.swift | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Tests/CollectionViewTests/ViewConfiguratorTests.swift diff --git a/Tests/CollectionViewTests/ViewConfiguratorTests.swift b/Tests/CollectionViewTests/ViewConfiguratorTests.swift new file mode 100644 index 00000000..df2e993b --- /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) + } +} -- GitLab