This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 385
/
Copy pathIssueLabelCellTests.swift
66 lines (48 loc) · 2.03 KB
/
IssueLabelCellTests.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// IssueLabelCellTests.swift
// FreetimeTests
//
// Created by Hesham Salman on 10/18/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import XCTest
@testable import Freetime
class IssueLabelCellTests: XCTestCase {
var issueLabelCell: IssueLabelCell!
override func setUp() {
super.setUp()
let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40.0)
issueLabelCell = IssueLabelCell(frame: frame)
}
func test_background_styling() {
let expectedCornerRadius = Styles.Sizes.avatarCornerRadius
let actualCornerRadius = issueLabelCell.background.layer.cornerRadius
XCTAssertEqual(expectedCornerRadius, actualCornerRadius)
XCTAssertTrue(issueLabelCell.background.subviews.contains(issueLabelCell.label))
}
func test_label_styling() {
let expectedFont = Styles.Text.smallTitle.preferredFont
let actualFont = issueLabelCell.label.font
XCTAssertEqual(expectedFont, actualFont)
}
func test_bindViewModel_repsitoryLabelViewModel() {
let viewModel = RepositoryLabel(color: "#FF0000", name: "Hello, world!")
issueLabelCell.bindViewModel(viewModel)
let expectedBackgroundColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1.0)
let actualBackgroundColor = issueLabelCell.background.backgroundColor
XCTAssertEqual(expectedBackgroundColor, actualBackgroundColor)
let expectedText = "Hello, world!"
let actualText = issueLabelCell.label.text
XCTAssertEqual(expectedText, actualText)
let expectedTextColor = expectedBackgroundColor.textOverlayColor
let actualTextColor = issueLabelCell.label.textColor
XCTAssertEqual(expectedTextColor, actualTextColor)
}
func test_bindViewModel_invalidViewModel() {
let defaultLabel = UILabel()
issueLabelCell.bindViewModel("")
XCTAssertNil(issueLabelCell.label.text)
XCTAssertEqual(defaultLabel.textColor, issueLabelCell.label.textColor)
}
}