Skip to content
Snippets Groups Projects
Commit 4484d801 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add example and tests for ViewConfigurator

parent 8f8499b3
No related branches found
No related tags found
2 merge requests!54Releasing 1.1.4,!51CollectionView library
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)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment