-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up RemoteConfigFeature+Helpers and RemoteConfigFeatureFlagToolsViewModel #1924
Changes from 1 commit
e7f905f
f61f882
71c858f
3a1b472
087267f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,102 +3,118 @@ import Prelude | |
import XCTest | ||
|
||
final class RemoteConfigFeatureHelpersTests: TestCase { | ||
func assertFeatureIsFalse(_ featureFlag: Bool, | ||
whenRemoteConfigFeatureIsFalse feature: RemoteConfigFeature) { | ||
func assertFeatureIsFalse( | ||
whenRemoteConfigFeatureIsFalse feature: RemoteConfigFeature, | ||
checkFeatureFlag: () -> Bool | ||
) { | ||
let mockRemoteConfigClient = MockRemoteConfigClient() | ||
|> \.features .~ [feature.rawValue: false] | ||
|
||
withEnvironment(remoteConfigClient: mockRemoteConfigClient) { | ||
XCTAssertFalse(featureFlag) | ||
XCTAssertFalse(checkFeatureFlag()) | ||
} | ||
} | ||
|
||
func assertFeatureIsTrue(_ featureFlag: Bool, whenRemoteConfigFeatureIsTrue feature: RemoteConfigFeature) { | ||
func assertFeatureIsTrue( | ||
whenRemoteConfigFeatureIsTrue feature: RemoteConfigFeature, | ||
checkFeatureFlag: () -> Bool | ||
) { | ||
let mockRemoteConfigClient = MockRemoteConfigClient() | ||
|> \.features .~ [feature.rawValue: true] | ||
|
||
withEnvironment(remoteConfigClient: mockRemoteConfigClient) { | ||
XCTAssertFalse(featureFlag) | ||
XCTAssertTrue(checkFeatureFlag()) | ||
} | ||
} | ||
|
||
func testBlockUsers_RemoteConfig_FeatureFlag_False() { | ||
self.assertFeatureIsFalse(featureBlockUsersEnabled(), whenRemoteConfigFeatureIsFalse: .blockUsersEnabled) | ||
self.assertFeatureIsFalse(whenRemoteConfigFeatureIsFalse: .blockUsersEnabled) { | ||
featureBlockUsersEnabled() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I could be wrong about this, but I don't think you need to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, you're correct. Will fix, that looks much nicer. |
||
} | ||
|
||
func testBlockUsers_RemoteConfig_FeatureFlag_True() { | ||
self.assertFeatureIsTrue(featureBlockUsersEnabled(), whenRemoteConfigFeatureIsTrue: .blockUsersEnabled) | ||
self.assertFeatureIsTrue(whenRemoteConfigFeatureIsTrue: .blockUsersEnabled) { | ||
featureBlockUsersEnabled() | ||
} | ||
} | ||
|
||
func testConsentManagementDialog_RemoteConfig_FeatureFlag_False() { | ||
self | ||
.assertFeatureIsFalse( | ||
featureConsentManagementDialogEnabled(), | ||
whenRemoteConfigFeatureIsFalse: .consentManagementDialogEnabled | ||
) | ||
) { | ||
featureConsentManagementDialogEnabled() | ||
} | ||
} | ||
|
||
func testConsentManagementDialog_RemoteConfig_FeatureFlag_True() { | ||
self | ||
.assertFeatureIsTrue( | ||
featureConsentManagementDialogEnabled(), | ||
whenRemoteConfigFeatureIsTrue: .consentManagementDialogEnabled | ||
) | ||
) { | ||
featureConsentManagementDialogEnabled() | ||
} | ||
} | ||
|
||
func testDarkMode_RemoteConfig_FeatureFlag_False() { | ||
self.assertFeatureIsFalse(featureDarkModeEnabled(), whenRemoteConfigFeatureIsFalse: .darkModeEnabled) | ||
self.assertFeatureIsFalse(whenRemoteConfigFeatureIsFalse: .darkModeEnabled) { | ||
featureDarkModeEnabled() | ||
} | ||
} | ||
|
||
func testDarkMode_RemoteConfig_FeatureFlag_True() { | ||
self.assertFeatureIsTrue(featureDarkModeEnabled(), whenRemoteConfigFeatureIsTrue: .darkModeEnabled) | ||
self.assertFeatureIsTrue(whenRemoteConfigFeatureIsTrue: .darkModeEnabled) { | ||
featureDarkModeEnabled() | ||
} | ||
} | ||
|
||
func testFacebookDeprecation_RemoteConfig_FeatureFlag_True() { | ||
self | ||
.assertFeatureIsTrue( | ||
featureFacebookLoginInterstitialEnabled(), | ||
whenRemoteConfigFeatureIsTrue: .facebookLoginInterstitialEnabled | ||
) | ||
.assertFeatureIsTrue(whenRemoteConfigFeatureIsTrue: .facebookLoginInterstitialEnabled | ||
) { | ||
featureFacebookLoginInterstitialEnabled() | ||
} | ||
} | ||
|
||
func testFacebookDeprecation_RemoteConfig_FeatureFlag_False() { | ||
self | ||
.assertFeatureIsFalse( | ||
featureFacebookLoginInterstitialEnabled(), | ||
whenRemoteConfigFeatureIsFalse: .facebookLoginInterstitialEnabled | ||
) | ||
.assertFeatureIsFalse(whenRemoteConfigFeatureIsFalse: .facebookLoginInterstitialEnabled | ||
) { | ||
featureFacebookLoginInterstitialEnabled() | ||
} | ||
} | ||
|
||
func testPostCampaignPledge_RemoteConfig_FeatureFlag_True() { | ||
self | ||
.assertFeatureIsTrue( | ||
featurePostCampaignPledgeEnabled(), | ||
whenRemoteConfigFeatureIsTrue: .postCampaignPledgeEnabled | ||
) | ||
.assertFeatureIsTrue(whenRemoteConfigFeatureIsTrue: .postCampaignPledgeEnabled | ||
) { | ||
featurePostCampaignPledgeEnabled() | ||
} | ||
} | ||
|
||
func testPostCampaignPledge_RemoteConfig_FeatureFlag_False() { | ||
self | ||
.assertFeatureIsFalse( | ||
featurePostCampaignPledgeEnabled(), | ||
whenRemoteConfigFeatureIsFalse: .postCampaignPledgeEnabled | ||
) | ||
) { | ||
featurePostCampaignPledgeEnabled() | ||
} | ||
} | ||
|
||
func testReportThisProject_RemoteConfig_FeatureFlag_True() { | ||
self | ||
.assertFeatureIsTrue( | ||
featureReportThisProjectEnabled(), | ||
whenRemoteConfigFeatureIsTrue: .reportThisProjectEnabled | ||
) | ||
) { featureReportThisProjectEnabled() } | ||
} | ||
|
||
func testReportThisProject_RemoteConfig_FeatureFlag_False() { | ||
self | ||
.assertFeatureIsFalse( | ||
featureReportThisProjectEnabled(), | ||
whenRemoteConfigFeatureIsFalse: .reportThisProjectEnabled | ||
) | ||
) { | ||
featureReportThisProjectEnabled() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 Great catch @ifosli. Soon as I swapped this to
XCTAssertTrue
the tests started failing!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now!