File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
WooCommerce/WooCommerceTests/ViewRelated/Coupons Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -111,4 +111,38 @@ final class CouponListViewModelTests: XCTestCase {
111111 // Then
112112 XCTAssertEqual ( sut. state, . empty)
113113 }
114+
115+ func test_refreshCoupon_updates_state_to_refreshing( ) {
116+ // Given
117+ setUpWithCouponFetched ( ) // we need to have existing data to enter refreshing state
118+
119+ // When
120+ sut. refreshCoupons ( )
121+
122+ // Then
123+ XCTAssertEqual ( sut. state, . refreshing)
124+ }
125+
126+ func test_refreshCoupons_calls_resynchronize_on_syncCoordinator( ) {
127+ // Given
128+ sut = CouponListViewModel ( siteID: 123 , syncingCoordinator: mockSyncingCoordinator)
129+
130+ // When
131+ sut. refreshCoupons ( )
132+
133+ // Then
134+ XCTAssert ( mockSyncingCoordinator. spyDidCallResynchronize)
135+ }
136+
137+ func test_handleCouponSyncResult_removes_refreshing_when_refresh_completes( ) {
138+ // Given
139+ setUpWithCouponFetched ( )
140+ sut. refreshCoupons ( )
141+
142+ // When
143+ sut. handleCouponSyncResult ( result: . success( false ) )
144+
145+ // Then
146+ XCTAssertEqual ( sut. state, . coupons)
147+ }
114148}
You can’t perform that action at this time.
0 commit comments