From ede08f5d7e93e1d846d5c3eb1619956d66f1b25f Mon Sep 17 00:00:00 2001 From: Jonathan Cole Date: Wed, 1 Dec 2021 14:03:20 -0500 Subject: [PATCH] Add tests to verify hairline config works properly after changes --- Example/Tests/StackableTests.swift | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Example/Tests/StackableTests.swift diff --git a/Example/Tests/StackableTests.swift b/Example/Tests/StackableTests.swift new file mode 100644 index 0000000..5d9e284 --- /dev/null +++ b/Example/Tests/StackableTests.swift @@ -0,0 +1,48 @@ +// +// StackableTests.swift +// +// +// Created by Jonathan Cole on 12/1/21. +// + +@testable import Stackable +import XCTest + +class StackableTests: XCTestCase { + + func testHairlineConfigLogic() { + // Test Global config + UIStackView.stackable.hairlineColor = .blue + let stack1 = UIStackView() + stack1.stackable.add([ + UIStackView.stackable.hairline, + ]) + let hairline1 = stack1.arrangedSubviews.first as! StackableHairlineView + XCTAssert(hairline1.backgroundColor == .blue) + + // Test instance config + let stack2 = UIStackView() + stack2.stackable.hairlineColor = .brown + stack2.stackable.add([ + UIStackView.stackable.hairline, + ]) + let hairline2 = stack2.arrangedSubviews.first as! StackableHairlineView + XCTAssert(hairline2.backgroundColor == .brown) + + // Test per-hairline Config + let stack3 = UIStackView() + stack3.stackable.hairlineColor = .brown + stack3.stackable.add([ + UIStackView.stackable.hairline, + UIStackView.stackable.hairline + .color(.yellow), + ]) + let hairline3 = stack3.arrangedSubviews.first as! StackableHairlineView + XCTAssert(hairline3.backgroundColor == .brown) + + let hairline4 = stack3.arrangedSubviews.last as! StackableHairlineView + XCTAssert(hairline4.backgroundColor == .yellow) + + } + +}