forked from SwifterSwift/SwifterSwift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUITabBarExtensionsTests.swift
34 lines (25 loc) · 1.14 KB
/
UITabBarExtensionsTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// UITabBarExtensionsTests.swift - Copyright 2023 SwifterSwift
@testable import SwifterSwift
import XCTest
#if canImport(UIKit) && !os(watchOS)
import UIKit
final class UITabBarExtensionsTests: XCTestCase {
func testSetColors() {
let frame = CGRect(x: 0, y: 0, width: 300, height: 44)
var tabBar = UITabBar(frame: frame)
tabBar.setColors(background: .red, selectedBackground: .orange, item: .white, selectedItem: .black)
XCTAssertEqual(tabBar.barTintColor, .red)
tabBar = UITabBar(frame: frame)
tabBar.setColors()
XCTAssertNotEqual(tabBar.barTintColor, .red)
let bundle = Bundle(for: UIImageExtensionsTests.self)
let image = UIImage(named: "TestImage", in: bundle, compatibleWith: nil)!
let item1 = UITabBarItem(title: "First", image: image, selectedImage: image)
let item2 = UITabBarItem(title: "Second", image: nil, selectedImage: nil)
tabBar.items = [item1, item2]
tabBar.selectedItem = item1
XCTAssertNotNil(tabBar.selectedItem)
tabBar.setColors(selectedBackground: .orange, item: .white, selectedItem: .black)
}
}
#endif