Skip to content

Commit 0aa5f69

Browse files
author
Alex Little
committed
Tests for collectionview supplementary views
1 parent c75e00f commit 0aa5f69

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Tests/CombineDataSourcesTests/CollectionView/CollectionViewItemsControllerTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ final class CollectionViewItemsControllerTests: XCTestCase {
4242
// Configure the controller
4343
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
4444
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
45+
collectionView.register(UICollectionReusableView.self, forSupplementaryViewOfKind: "supplementary-kind", withReuseIdentifier: "supplementaryview")
46+
47+
ctr.configureSupplementaryView = { _, collection, kind, index, section -> UICollectionReusableView in
48+
return collection.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "supplementaryview", for: index)
49+
}
4550

4651
ctr.collectionView = collectionView
4752
ctr.updateCollection(dataSet2)
4853

4954
XCTAssertNil(lastModel)
5055
let cell = ctr.collectionView(collectionView, cellForItemAt: IndexPath(row: 0, section: 0))
56+
let supplementaryView = ctr.collectionView(collectionView, viewForSupplementaryElementOfKind: "supplementary-kind", at: IndexPath(row: 0, section: 0))
5157
XCTAssertNotNil(cell)
58+
XCTAssertNotNil(supplementaryView)
5259
XCTAssertEqual("test model", lastModel?.text)
5360
}
5461
}

0 commit comments

Comments
 (0)