From 415af045ecae9ee7d481bd59c658fd3cdc363435 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Mon, 21 Dec 2015 01:20:28 +0100 Subject: [PATCH] Add tests for optional `cellType`. --- .../RxCocoaTests/Control+RxTests+UIKit.swift | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift index 0f236cd4..42b931c6 100644 --- a/Tests/RxCocoaTests/Control+RxTests+UIKit.swift +++ b/Tests/RxCocoaTests/Control+RxTests+UIKit.swift @@ -89,6 +89,23 @@ extension ControlTests { ensureEventDeallocated(createView) { (view: UICollectionView) in view.rx_modelSelected(Int.self) } } + func testCollectionView_DelegateEventCompletesOnDealloc2_cellType() { + let items: Observable<[Int]> = just([1, 2, 3]) + + let layout = UICollectionViewFlowLayout() + + let createView: () -> (UICollectionView, Disposable) = { + let collectionView = UICollectionView(frame: CGRectMake(0, 0, 1, 1), collectionViewLayout: layout) + collectionView.registerClass(NSClassFromString("UICollectionViewCell"), forCellWithReuseIdentifier: "a") + let s = items.bindTo(collectionView.rx_itemsWithCellIdentifier("a", cellType: UICollectionViewCell.self)) { (index: Int, item: Int, cell) in + + } + + return (collectionView, s) + } + ensureEventDeallocated(createView) { (view: UICollectionView) in view.rx_modelSelected(Int.self) } + } + func testCollectionView_ModelSelected1() { let items: Observable<[Int]> = just([1, 2, 3]) @@ -211,6 +228,21 @@ extension ControlTests { ensureEventDeallocated(createView) { (view: UITableView) in view.rx_modelSelected(Int.self) } } + func testTableView_DelegateEventCompletesOnDealloc2_cellType() { + let items: Observable<[Int]> = just([1, 2, 3]) + + let createView: () -> (UITableView, Disposable) = { + let tableView = UITableView(frame: CGRectMake(0, 0, 1, 1)) + tableView.registerClass(NSClassFromString("UITableViewCell"), forCellReuseIdentifier: "a") + let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellIdentifier("a", cellType: UITableViewCell.self)) { (index: Int, item: Int, cell) in + + } + + return (tableView, dataSourceSubscription) + } + ensureEventDeallocated(createView) { (view: UITableView) in view.rx_modelSelected(Int.self) } + } + func testTableView_ModelSelected1() { let items: Observable<[Int]> = just([1, 2, 3])