-
Notifications
You must be signed in to change notification settings - Fork 499
/
Copy pathRxCollectionViewSectionedDataSource+Test.swift
117 lines (99 loc) · 5.51 KB
/
RxCollectionViewSectionedDataSource+Test.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// RxCollectionViewSectionedDataSource+Test.swift
// Tests
//
// Created by Krunoslav Zaher on 11/4/17.
// Copyright © 2017 kzaher. All rights reserved.
//
#if os(iOS)
import Foundation
import RxDataSources
import XCTest
import UIKit
class RxCollectionViewSectionedDataSourceTest: XCTestCase {
}
// configureSupplementaryView not passed through init
extension RxCollectionViewSectionedDataSourceTest {
func testCollectionViewSectionedReloadDataSource_optionalConfigureSupplementaryView() {
let dataSource = RxCollectionViewSectionedReloadDataSource<AnimatableSectionModel<String, String>>(configureCell: { _, _, _, _ in UICollectionViewCell() })
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
XCTAssertFalse(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
let sentinel = UICollectionReusableView()
dataSource.configureSupplementaryView = { _, _, _, _ in return sentinel }
let returnValue = dataSource.collectionView(
collectionView,
viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader,
at: IndexPath(item: 0, section: 0)
)
XCTAssertEqual(returnValue, sentinel)
XCTAssertTrue(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
}
func testCollectionViewSectionedDataSource_optionalConfigureSupplementaryView() {
let dataSource = CollectionViewSectionedDataSource<AnimatableSectionModel<String, String>>(configureCell: { _, _, _, _ in UICollectionViewCell() })
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
XCTAssertFalse(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
let sentinel = UICollectionReusableView()
dataSource.configureSupplementaryView = { _, _, _, _ in return sentinel }
let returnValue = dataSource.collectionView(
collectionView,
viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader,
at: IndexPath(item: 0, section: 0)
)
XCTAssertEqual(returnValue, sentinel)
XCTAssertTrue(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
}
}
// configureSupplementaryView passed through init
extension RxCollectionViewSectionedDataSourceTest {
func testCollectionViewSectionedAnimatedDataSource_optionalConfigureSupplementaryView_initializer() {
let sentinel = UICollectionReusableView()
let dataSource = RxCollectionViewSectionedAnimatedDataSource<AnimatableSectionModel<String, String>>(
configureCell: { _, _, _, _ in UICollectionViewCell() },
configureSupplementaryView: { _, _, _, _ in return sentinel }
)
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
let returnValue = dataSource.collectionView(
collectionView,
viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader,
at: IndexPath(item: 0, section: 0)
)
XCTAssertEqual(returnValue, sentinel)
XCTAssertTrue(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
}
func testCollectionViewSectionedReloadDataSource_optionalConfigureSupplementaryView_initializer() {
let sentinel = UICollectionReusableView()
let dataSource = RxCollectionViewSectionedReloadDataSource<AnimatableSectionModel<String, String>>(
configureCell: { _, _, _, _ in UICollectionViewCell() },
configureSupplementaryView: { _, _, _, _ in return sentinel }
)
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
let returnValue = dataSource.collectionView(
collectionView,
viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader,
at: IndexPath(item: 0, section: 0)
)
XCTAssertEqual(returnValue, sentinel)
XCTAssertTrue(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
}
func testCollectionViewSectionedDataSource_optionalConfigureSupplementaryView_initializer() {
let sentinel = UICollectionReusableView()
let dataSource = CollectionViewSectionedDataSource<AnimatableSectionModel<String, String>>(
configureCell: { _, _, _, _ in UICollectionViewCell() },
configureSupplementaryView: { _, _, _, _ in return sentinel }
)
let layout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
let returnValue = dataSource.collectionView(
collectionView,
viewForSupplementaryElementOfKind: UICollectionView.elementKindSectionHeader,
at: IndexPath(item: 0, section: 0)
)
XCTAssertEqual(returnValue, sentinel)
XCTAssertTrue(dataSource.responds(to: #selector(UICollectionViewDataSource.collectionView(_:viewForSupplementaryElementOfKind:at:))))
}
}
#endif