Skip to content

Commit 6962c17

Browse files
committed
test for getPOSSurveyNotificationScheduled
1 parent e8391fc commit 6962c17

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Modules/Sources/Yosemite/Stores/AppSettingsStore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ private extension AppSettingsStore {
13041304
}
13051305

13061306
func getPOSSurveyNotificationScheduled(onCompletion: (Bool) -> Void) {
1307-
// TODO
1307+
onCompletion(generalAppSettings.value(for: \.isPOSSurveyNotificationScheduled))
13081308
}
13091309

13101310
func resetPOSSurveyNotificationScheduled(onCompletion: (Result<Void, Error>) -> Void) {

Modules/Tests/StorageTests/Model/AppSettings/GeneralAppSettingsTests.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ final class GeneralAppSettingsTests: XCTestCase {
5151
XCTAssertEqual(newSettings.feedbacks[.general], newFeedback)
5252
}
5353

54+
func test_isPOSSurveyNotificationScheduled_defaults_to_false() {
55+
// Given
56+
let settings = createGeneralAppSettings()
57+
58+
// Then
59+
XCTAssertFalse(settings.isPOSSurveyNotificationScheduled)
60+
}
61+
5462
func test_updating_properties_to_generalAppSettings_does_not_breaks_decoding() throws {
5563
// Given
5664
let installationDate = Date(timeIntervalSince1970: 1630314000) // Mon Aug 30 2021 09:00:00 UTC+0000
@@ -63,6 +71,7 @@ final class GeneralAppSettingsTests: XCTestCase {
6371
FeatureAnnouncementCampaignSettings(dismissedDate: Date(), remindAfter: nil)]
6472
let sitesWithAtLeastOneIPPTransactionFinished: Set<Int64> = [1234, 123, 12, 1]
6573
let isCustomFieldsTopBannerDismissed = true
74+
let isPOSSurveyNotificationScheduled = true
6675
let previousSettings = GeneralAppSettings(installationDate: installationDate,
6776
feedbacks: feedbackSettings,
6877
isViewAddOnsSwitchEnabled: true,
@@ -74,13 +83,14 @@ final class GeneralAppSettingsTests: XCTestCase {
7483
sitesWithAtLeastOneIPPTransactionFinished: sitesWithAtLeastOneIPPTransactionFinished,
7584
isEUShippingNoticeDismissed: false,
7685
isCustomFieldsTopBannerDismissed: isCustomFieldsTopBannerDismissed,
77-
isPOSSurveyNotificationScheduled: false)
86+
isPOSSurveyNotificationScheduled: isPOSSurveyNotificationScheduled)
7887

7988
let previousEncodedSettings = try JSONEncoder().encode(previousSettings)
8089
var previousSettingsJson = try JSONSerialization.jsonObject(with: previousEncodedSettings, options: .allowFragments) as? [String: Any]
8190

8291
// When
8392
previousSettingsJson?.removeValue(forKey: "isViewAddOnsSwitchEnabled")
93+
previousSettingsJson?.removeValue(forKey: "isPOSSurveyNotificationScheduled")
8494
let newEncodedSettings = try JSONSerialization.data(withJSONObject: previousSettingsJson as Any, options: .fragmentsAllowed)
8595
let newSettings = try JSONDecoder().decode(GeneralAppSettings.self, from: newEncodedSettings)
8696

@@ -94,6 +104,7 @@ final class GeneralAppSettingsTests: XCTestCase {
94104
assertEqual(newSettings.featureAnnouncementCampaignSettings, featureAnnouncementCampaignSettings)
95105
assertEqual(newSettings.sitesWithAtLeastOneIPPTransactionFinished, sitesWithAtLeastOneIPPTransactionFinished)
96106
assertEqual(newSettings.isCustomFieldsTopBannerDismissed, isCustomFieldsTopBannerDismissed)
107+
assertEqual(newSettings.isPOSSurveyNotificationScheduled, false)
97108
}
98109
}
99110

Modules/Tests/YosemiteTests/Stores/AppSettingsStoreTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,25 @@ extension AppSettingsStoreTests {
15061506
// Then
15071507
XCTAssertNil(loadedOrderStatus)
15081508
}
1509+
1510+
// MARK: - Point of Sale Survey Notification
1511+
1512+
func test_getPOSSurveyNotificationScheduled_returns_false_on_new_generalAppSettings() throws {
1513+
// Given
1514+
try fileStorage?.deleteFile(at: expectedGeneralAppSettingsFileURL)
1515+
1516+
// When
1517+
let result: Bool = waitFor { promise in
1518+
let action = AppSettingsAction.getPOSSurveyNotificationScheduled { isScheduled in
1519+
promise(isScheduled)
1520+
}
1521+
self.subject?.onAction(action)
1522+
}
1523+
1524+
// Then
1525+
XCTAssertFalse(result)
1526+
}
1527+
15091528
}
15101529

15111530
// MARK: - Utils

0 commit comments

Comments
 (0)