Skip to content

Commit c087890

Browse files
committed
Update unit test for coupon list view model
1 parent 71122f9 commit c087890

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

WooCommerce/WooCommerceTests/ViewRelated/Coupons/CouponListViewModelTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,24 @@ final class CouponListViewModelTests: XCTestCase {
145145
// Then
146146
XCTAssertEqual(sut.state, .coupons)
147147
}
148+
149+
func test_tableWillDisplayCellAtIndexPath_calls_ensureNextPageIsSynchronized_on_syncCoordinator() {
150+
// Given
151+
sut = CouponListViewModel(siteID: 123, syncingCoordinator: mockSyncingCoordinator)
152+
153+
// When
154+
sut.tableWillDisplayCell(at: IndexPath(row: 3, section: 0))
155+
156+
// Then
157+
XCTAssertTrue(mockSyncingCoordinator.spyDidCallEnsureNextPageIsSynchronized)
158+
XCTAssertEqual(mockSyncingCoordinator.spyEnsureNextPageIsSynchronizedLastVisibleIndex, 3)
159+
}
160+
161+
func test_sync_updates_state_correctly_when_syncing_next_page() {
162+
// When
163+
sut.sync(pageNumber: 2, pageSize: 10, reason: nil, onCompletion: nil)
164+
165+
// Then
166+
XCTAssertEqual(sut.state, .loadingNextPage)
167+
}
148168
}

0 commit comments

Comments
 (0)