File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Tests/YosemiteTests/Stores Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -1313,7 +1313,12 @@ private extension AppSettingsStore {
13131313 }
13141314
13151315 func resetPOSSurveyNotificationScheduled( onCompletion: ( Result < Void , Error > ) -> Void ) {
1316- // TODO
1316+ do {
1317+ try generalAppSettings. setValue ( false , for: \. isPOSSurveyNotificationScheduled)
1318+ onCompletion ( . success( ( ) ) )
1319+ } catch {
1320+ onCompletion ( . failure( error) )
1321+ }
13171322 }
13181323}
13191324
Original file line number Diff line number Diff line change @@ -1560,6 +1560,42 @@ extension AppSettingsStoreTests {
15601560 let savedSettings : GeneralAppSettings = try XCTUnwrap ( fileStorage? . data ( for: expectedGeneralAppSettingsFileURL) )
15611561 XCTAssertTrue ( savedSettings. isPOSSurveyNotificationScheduled)
15621562 }
1563+
1564+ func test_resetPOSSurveyNotificationScheduled_resets_to_false_after_being_set_to_true( ) throws {
1565+ // Given
1566+ try fileStorage? . deleteFile ( at: expectedGeneralAppSettingsFileURL)
1567+
1568+ // 1. Set to true
1569+ let setAction = AppSettingsAction . setPOSSurveyNotificationScheduled { _ in }
1570+ subject? . onAction ( setAction)
1571+
1572+ // 2. Verify it's true
1573+ let checkBeforeReset : Bool = waitFor { promise in
1574+ let action = AppSettingsAction . getPOSSurveyNotificationScheduled { isScheduled in
1575+ promise ( isScheduled)
1576+ }
1577+ self . subject? . onAction ( action)
1578+ }
1579+ XCTAssertTrue ( checkBeforeReset)
1580+
1581+ // When - 3. Reset it
1582+ var resetResult : Result < Void , Error > ?
1583+ let resetAction = AppSettingsAction . resetPOSSurveyNotificationScheduled { aResult in
1584+ resetResult = aResult
1585+ }
1586+ subject? . onAction ( resetAction)
1587+
1588+ // Then - 4. Verify it's false
1589+ XCTAssertTrue ( try XCTUnwrap ( resetResult) . isSuccess)
1590+
1591+ let checkAfterReset : Bool = waitFor { promise in
1592+ let action = AppSettingsAction . getPOSSurveyNotificationScheduled { isScheduled in
1593+ promise ( isScheduled)
1594+ }
1595+ self . subject? . onAction ( action)
1596+ }
1597+ XCTAssertFalse ( checkAfterReset)
1598+ }
15631599}
15641600
15651601// MARK: - Utils
You can’t perform that action at this time.
0 commit comments