Skip to content

Commit 062a834

Browse files
committed
Update unit tests with order creation beta switch
1 parent 686f911 commit 062a834

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

Storage/StorageTests/Model/AppSettings/GeneralAppSettingsTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class GeneralAppSettingsTests: XCTestCase {
1010
feedbacks: [.general: feedback],
1111
isViewAddOnsSwitchEnabled: false,
1212
isSimplePaymentsSwitchEnabled: false,
13+
isOrderCreationSwitchEnabled: false,
1314
knownCardReaders: [])
1415

1516
// When
@@ -25,6 +26,7 @@ class GeneralAppSettingsTests: XCTestCase {
2526
feedbacks: [:],
2627
isViewAddOnsSwitchEnabled: false,
2728
isSimplePaymentsSwitchEnabled: false,
29+
isOrderCreationSwitchEnabled: false,
2830
knownCardReaders: [])
2931

3032
// When
@@ -42,6 +44,7 @@ class GeneralAppSettingsTests: XCTestCase {
4244
feedbacks: [.general: existingFeedback],
4345
isViewAddOnsSwitchEnabled: false,
4446
isSimplePaymentsSwitchEnabled: false,
47+
isOrderCreationSwitchEnabled: false,
4548
knownCardReaders: []
4649
)
4750

@@ -59,6 +62,7 @@ class GeneralAppSettingsTests: XCTestCase {
5962
feedbacks: [:],
6063
isViewAddOnsSwitchEnabled: false,
6164
isSimplePaymentsSwitchEnabled: false,
65+
isOrderCreationSwitchEnabled: false,
6266
knownCardReaders: [])
6367

6468
// When
@@ -79,6 +83,7 @@ class GeneralAppSettingsTests: XCTestCase {
7983
feedbacks: feedbackSettings,
8084
isViewAddOnsSwitchEnabled: true,
8185
isSimplePaymentsSwitchEnabled: true,
86+
isOrderCreationSwitchEnabled: true,
8287
knownCardReaders: readers,
8388
lastEligibilityErrorInfo: eligibilityInfo)
8489

@@ -97,5 +102,6 @@ class GeneralAppSettingsTests: XCTestCase {
97102
assertEqual(newSettings.lastEligibilityErrorInfo, eligibilityInfo)
98103
assertEqual(newSettings.isViewAddOnsSwitchEnabled, false)
99104
assertEqual(newSettings.isSimplePaymentsSwitchEnabled, true)
105+
assertEqual(newSettings.isOrderCreationSwitchEnabled, true)
100106
}
101107
}

Yosemite/YosemiteTests/Stores/AppSettings/InAppFeedbackCardVisibilityUseCaseTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ final class InAppFeedbackCardVisibilityUseCaseTests: XCTestCase {
160160
let settings = GeneralAppSettings(installationDate: nil,
161161
feedbacks: [:], isViewAddOnsSwitchEnabled: false,
162162
isSimplePaymentsSwitchEnabled: false,
163+
isOrderCreationSwitchEnabled: false,
163164
knownCardReaders: [])
164165
let useCase = InAppFeedbackCardVisibilityUseCase(settings: settings, feedbackType: .productsVariations)
165166

@@ -225,6 +226,7 @@ private extension InAppFeedbackCardVisibilityUseCaseTests {
225226
feedbacks: [feedback.name: feedback],
226227
isViewAddOnsSwitchEnabled: false,
227228
isSimplePaymentsSwitchEnabled: false,
229+
isOrderCreationSwitchEnabled: false,
228230
knownCardReaders: []
229231
)
230232
return settings

Yosemite/YosemiteTests/Stores/AppSettingsStoreTests.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,42 @@ final class AppSettingsStoreTests: XCTestCase {
483483
XCTAssertTrue(isEnabled)
484484
}
485485

486+
func test_loadOrderCreationSwitchState_returns_false_on_new_generalAppSettings() throws {
487+
// Given
488+
try fileStorage?.deleteFile(at: expectedGeneralAppSettingsFileURL)
489+
490+
// When
491+
let result: Result<Bool, Error> = waitFor { promise in
492+
let action = AppSettingsAction.loadOrderCreationSwitchState { result in
493+
promise(result)
494+
}
495+
self.subject?.onAction(action)
496+
}
497+
498+
// Then
499+
let isEnabled = try result.get()
500+
XCTAssertFalse(isEnabled)
501+
}
502+
503+
func test_loadOrderCreationSwitchState_returns_true_after_updating_switch_state_to_true() throws {
504+
// Given
505+
try fileStorage?.deleteFile(at: expectedGeneralAppSettingsFileURL)
506+
let updateAction = AppSettingsAction.setOrderCreationFeatureSwitchState(isEnabled: true, onCompletion: { _ in })
507+
subject?.onAction(updateAction)
508+
509+
// When
510+
let result: Result<Bool, Error> = waitFor { promise in
511+
let action = AppSettingsAction.loadOrderCreationSwitchState { result in
512+
promise(result)
513+
}
514+
self.subject?.onAction(action)
515+
}
516+
517+
// Then
518+
let isEnabled = try result.get()
519+
XCTAssertTrue(isEnabled)
520+
}
521+
486522
// MARK: - General Store Settings
487523

488524
func test_saving_isTelemetryAvailable_works_correctly() throws {
@@ -642,6 +678,7 @@ private extension AppSettingsStoreTests {
642678
feedbacks: [feedback.name: feedback],
643679
isViewAddOnsSwitchEnabled: false,
644680
isSimplePaymentsSwitchEnabled: false,
681+
isOrderCreationSwitchEnabled: false,
645682
knownCardReaders: []
646683
)
647684
return (settings, feedback)

0 commit comments

Comments
 (0)