forked from vtourraine/AcknowList
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AcknowListViewControllerTests.swift
57 lines (46 loc) · 2.45 KB
/
AcknowListViewControllerTests.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
//
// AcknowListViewControllerTests.swift
// AcknowExample
//
// Created by Vincent Tourraine on 22/08/15.
// Copyright © 2015-2020 Vincent Tourraine. All rights reserved.
//
import UIKit
import XCTest
@testable import AcknowList
class AcknowListViewControllerTests: XCTestCase {
func testConfigureTableView() {
let bundle = Bundle(for: AcknowListViewControllerTests.self)
let plistPath = bundle.path(forResource: "Pods-acknowledgements", ofType: "plist")
let viewController = AcknowListViewController(acknowledgementsPlistPath: plistPath)
XCTAssertEqual(viewController.numberOfSections(in: viewController.tableView), 1)
XCTAssertEqual(viewController.tableView(viewController.tableView, numberOfRowsInSection: 0), 1)
let cell = viewController.tableView(viewController.tableView, cellForRowAt: IndexPath(row: 0, section: 0))
XCTAssertEqual(cell.textLabel?.text, "AcknowList")
}
func testSortsAcknowledgementsByTitle() {
let bundle = Bundle(for: AcknowListViewControllerTests.self)
let plistPath = bundle.path(forResource: "Pods-acknowledgements-multi", ofType: "plist")
let viewController = AcknowListViewController(acknowledgementsPlistPath: plistPath)
XCTAssertEqual(viewController.acknowledgements?.count, 3)
XCTAssertEqual(viewController.acknowledgements?[0].title, "A title")
XCTAssertEqual(viewController.acknowledgements?[1].title, "B title")
XCTAssertEqual(viewController.acknowledgements?[2].title, "C title")
}
func testLoadFromMultiplePlist() {
let bundle = Bundle(for: AcknowListViewControllerTests.self)
let plistPath1 = bundle.path(forResource: "Pods-acknowledgements", ofType: "plist")
let plistPath2 = bundle.path(forResource: "Pods-acknowledgements-multi", ofType: "plist")
if let plistPath1 = plistPath1, let plistPath2 = plistPath2 {
let viewController = AcknowListViewController(acknowledgementsPlistPaths: [plistPath1, plistPath2])
XCTAssertEqual(viewController.acknowledgements?.count, 4)
XCTAssertEqual(viewController.acknowledgements?[0].title, "A title")
XCTAssertEqual(viewController.acknowledgements?[1].title, "AcknowList")
XCTAssertEqual(viewController.acknowledgements?[2].title, "B title")
XCTAssertEqual(viewController.acknowledgements?[3].title, "C title")
}
else {
XCTFail()
}
}
}