Skip to content

Commit 24bae9e

Browse files
committed
Add a workaround for unit tests
1 parent 6418a53 commit 24bae9e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Modules/Sources/BuildSettingsKit/BuildSettingsEnvironment.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Foundation
22

3-
enum BuildSettingsEnvironment {
3+
public enum BuildSettingsEnvironment: Sendable {
44
case live
55
case preview
66
case test
77

8-
static let current: BuildSettingsEnvironment = {
8+
public static let current: BuildSettingsEnvironment = {
99
#if DEBUG
1010
let processInfo = ProcessInfo.processInfo
1111
if processInfo.isXcodePreview {

Modules/Sources/DesignSystem/Foundation/AppColor.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ public enum UIAppColor {
88
///
99
/// - note: The Jetpack app uses
1010
public static var tint: UIColor {
11-
switch BuildSettings.current.brand {
11+
switch AppBrand.current {
1212
case .wordpress: primary
1313
case .jetpack: UIColor.label
1414
}
1515
}
1616

1717
public static var primary: UIColor {
18-
switch BuildSettings.current.brand {
18+
switch AppBrand.current {
1919
case .wordpress: UIColor(light: CSColor.Blue.base, dark: primary(.shade40))
2020
case .jetpack: UIColor(light: CSColor.JetpackGreen.shade(.shade40), dark: CSColor.JetpackGreen.shade(.shade30))
2121
}
2222
}
2323

2424
public static func primary(_ shade: ColorStudioShade) -> UIColor {
25-
switch BuildSettings.current.brand {
25+
switch AppBrand.current {
2626
case .wordpress: CSColor.Blue.shade(shade)
2727
case .jetpack: CSColor.JetpackGreen.shade(shade)
2828
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
import BuildSettingsKit
3+
4+
extension AppBrand {
5+
static var current: AppBrand {
6+
// TODO: remove this when unit tests not longer rely on `BuildSettings.current`.
7+
if BuildSettingsEnvironment.current == .test {
8+
return .jetpack
9+
}
10+
return BuildSettings.current.brand
11+
}
12+
}

0 commit comments

Comments
 (0)