1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ import FirebaseAuth
1516@testable import FirebaseAuthSwiftUI
16- import Testing
1717import Foundation
18- import FirebaseAuth
18+ import Testing
1919
2020@Test func testStringUtilsDefaultBundle( ) async throws {
2121 // Test that StringUtils works with default bundle (no fallback)
2222 let stringUtils = StringUtils ( bundle: Bundle . module)
23-
23+
2424 let result = stringUtils. authPickerTitle
2525 #expect( result == " Sign in with Firebase " )
2626}
@@ -29,43 +29,43 @@ import FirebaseAuth
2929 // Test that StringUtils automatically falls back to module bundle for missing strings
3030 // When using main bundle (which doesn't have the strings), it should fall back to module bundle
3131 let stringUtils = StringUtils ( bundle: Bundle . main)
32-
32+
3333 let result = stringUtils. authPickerTitle
3434 // Should automatically fall back to module bundle since main bundle doesn't have this string
3535 #expect( result == " Sign in with Firebase " )
3636}
3737
3838@Test func testStringUtilsEmailInputLabel( ) async throws {
3939 let stringUtils = StringUtils ( bundle: Bundle . module)
40-
40+
4141 let result = stringUtils. emailInputLabel
4242 #expect( result == " Enter your email " )
4343}
4444
4545@Test func testStringUtilsPasswordInputLabel( ) async throws {
4646 let stringUtils = StringUtils ( bundle: Bundle . module)
47-
47+
4848 let result = stringUtils. passwordInputLabel
4949 #expect( result == " Enter your password " )
5050}
5151
5252@Test func testStringUtilsGoogleLoginButton( ) async throws {
5353 let stringUtils = StringUtils ( bundle: Bundle . module)
54-
54+
5555 let result = stringUtils. googleLoginButtonLabel
5656 #expect( result == " Sign in with Google " )
5757}
5858
5959@Test func testStringUtilsAppleLoginButton( ) async throws {
6060 let stringUtils = StringUtils ( bundle: Bundle . module)
61-
61+
6262 let result = stringUtils. appleLoginButtonLabel
6363 #expect( result == " Sign in with Apple " )
6464}
6565
6666@Test func testStringUtilsErrorMessages( ) async throws {
6767 let stringUtils = StringUtils ( bundle: Bundle . module)
68-
68+
6969 // Test various error message strings
7070 #expect( !stringUtils. alertErrorTitle. isEmpty)
7171 #expect( !stringUtils. passwordRecoveryTitle. isEmpty)
@@ -74,7 +74,7 @@ import FirebaseAuth
7474
7575@Test func testStringUtilsMFAStrings( ) async throws {
7676 let stringUtils = StringUtils ( bundle: Bundle . module)
77-
77+
7878 // Test MFA-related strings
7979 #expect( !stringUtils. twoFactorAuthenticationLabel. isEmpty)
8080 #expect( !stringUtils. enterVerificationCodeLabel. isEmpty)
@@ -86,16 +86,17 @@ import FirebaseAuth
8686@Test func testStringUtilsWithCustomStringsFileOverride( ) async throws {
8787 // Test that .strings file overrides work with automatic fallback
8888 guard let testBundle = createTestBundleWithStringsFile ( ) else {
89- Issue . record ( " Test bundle with .strings file not available - check TestResources/StringsOverride " )
89+ Issue
90+ . record ( " Test bundle with .strings file not available - check TestResources/StringsOverride " )
9091 return
9192 }
92-
93+
9394 let stringUtils = StringUtils ( bundle: testBundle)
94-
95+
9596 // Test overridden strings (should come from custom bundle)
9697 #expect( stringUtils. authPickerTitle == " Custom Sign In Title " )
9798 #expect( stringUtils. emailInputLabel == " Custom Email " )
98-
99+
99100 // Test non-overridden strings (should fall back to default)
100101 #expect( stringUtils. passwordInputLabel == " Enter your password " )
101102 #expect( stringUtils. googleLoginButtonLabel == " Sign in with Google " )
@@ -108,16 +109,16 @@ import FirebaseAuth
108109 Issue . record ( " Test bundle with .strings file not available " )
109110 return
110111 }
111-
112+
112113 let stringUtils = StringUtils ( bundle: testBundle)
113-
114+
114115 // Create a mock auth error
115116 let error = NSError (
116117 domain: " FIRAuthErrorDomain " ,
117118 code: AuthErrorCode . invalidEmail. rawValue,
118119 userInfo: nil
119120 )
120-
121+
121122 let errorMessage = stringUtils. localizedErrorMessage ( for: error)
122123 // Should fall back to default error message since we didn't override it
123124 #expect( errorMessage == " That email address isn't correct. " )
@@ -129,17 +130,18 @@ import FirebaseAuth
129130 Issue . record ( " Test bundle with multi-language strings not available " )
130131 return
131132 }
132-
133+
133134 // Test with Spanish language code
134135 let stringUtilsES = StringUtils ( bundle: testBundle, languageCode: " es " )
135-
136+
136137 // Overridden Spanish string
137138 #expect( stringUtilsES. authPickerTitle == " Título Personalizado " )
138-
139+
139140 // Non-overridden should fall back to default (from module bundle)
140141 // The fallback should return the default English string since Spanish isn't in module bundle
141142 #expect( !stringUtilsES. passwordInputLabel. isEmpty)
142- #expect( stringUtilsES. emailInputLabel != " Enter your email " || stringUtilsES. emailInputLabel == " Enter your email " )
143+ #expect( stringUtilsES. emailInputLabel != " Enter your email " || stringUtilsES
144+ . emailInputLabel == " Enter your email " )
143145}
144146
145147@Test func testStringUtilsMixedOverrideScenario( ) async throws {
@@ -148,15 +150,15 @@ import FirebaseAuth
148150 Issue . record ( " Test bundle with .strings file not available " )
149151 return
150152 }
151-
153+
152154 let stringUtils = StringUtils ( bundle: testBundle)
153-
155+
154156 // Verify custom strings are overridden
155157 let customStrings = [
156158 stringUtils. authPickerTitle,
157- stringUtils. emailInputLabel
159+ stringUtils. emailInputLabel,
158160 ]
159-
161+
160162 // Verify these use default fallback strings
161163 let defaultStrings = [
162164 stringUtils. passwordInputLabel,
@@ -165,18 +167,18 @@ import FirebaseAuth
165167 stringUtils. facebookLoginButtonLabel,
166168 stringUtils. phoneLoginButtonLabel,
167169 stringUtils. signOutButtonLabel,
168- stringUtils. deleteAccountButtonLabel
170+ stringUtils. deleteAccountButtonLabel,
169171 ]
170-
172+
171173 // All strings should be non-empty
172- customStrings . forEach { str in
174+ for str in customStrings {
173175 #expect( !str. isEmpty, " Custom string should not be empty " )
174176 }
175-
176- defaultStrings . forEach { str in
177+
178+ for str in defaultStrings {
177179 #expect( !str. isEmpty, " Default fallback string should not be empty " )
178180 }
179-
181+
180182 // Verify specific fallback values
181183 #expect( stringUtils. passwordInputLabel == " Enter your password " )
182184 #expect( stringUtils. googleLoginButtonLabel == " Sign in with Google " )
@@ -185,7 +187,7 @@ import FirebaseAuth
185187@Test func testStringUtilsAllDefaultStringsAreFallbackable( ) async throws {
186188 // Test that all strings can be accessed even with empty custom bundle
187189 let stringUtils = StringUtils ( bundle: Bundle . main)
188-
190+
189191 // Test a comprehensive list of strings to ensure they all fall back correctly
190192 let allStrings = [
191193 stringUtils. authPickerTitle,
@@ -207,13 +209,16 @@ import FirebaseAuth
207209 stringUtils. signUpWithEmailButtonLabel,
208210 stringUtils. backButtonLabel,
209211 stringUtils. okButtonLabel,
210- stringUtils. cancelButtonLabel
212+ stringUtils. cancelButtonLabel,
211213 ]
212-
214+
213215 // All should have values from the fallback bundle
214- allStrings . forEach { str in
216+ for str in allStrings {
215217 #expect( !str. isEmpty, " All strings should have fallback values " )
216- #expect( str != " Sign in with Firebase " || str == " Sign in with Firebase " , " Strings should be valid " )
218+ #expect(
219+ str != " Sign in with Firebase " || str == " Sign in with Firebase " ,
220+ " Strings should be valid "
221+ )
217222 }
218223}
219224
@@ -225,14 +230,14 @@ private func createTestBundleWithStringsFile() -> Bundle? {
225230 guard let resourceURL = Bundle . module. resourceURL else {
226231 return nil
227232 }
228-
233+
229234 let stringsOverridePath = resourceURL
230235 . appendingPathComponent ( " StringsOverride " )
231-
236+
232237 guard FileManager . default. fileExists ( atPath: stringsOverridePath. path) else {
233238 return nil
234239 }
235-
240+
236241 return Bundle ( url: stringsOverridePath)
237242}
238243
@@ -242,14 +247,13 @@ private func createTestBundleWithMultiLanguageStrings() -> Bundle? {
242247 guard let resourceURL = Bundle . module. resourceURL else {
243248 return nil
244249 }
245-
250+
246251 let multiLanguagePath = resourceURL
247252 . appendingPathComponent ( " MultiLanguage " )
248-
253+
249254 guard FileManager . default. fileExists ( atPath: multiLanguagePath. path) else {
250255 return nil
251256 }
252-
257+
253258 return Bundle ( url: multiLanguagePath)
254259}
255-
0 commit comments