Skip to content

Commit d4996ec

Browse files
committed
♻️ Extract helper method (#2446)
1 parent fe27b1b commit d4996ec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib/utils/auth_forms.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const createAuthFormWithFallback = async () => {
3333

3434
return result;
3535
} catch (error) {
36-
if (import.meta.env.DEV) {
36+
if (isDevelopmentMode()) {
3737
console.warn(`Failed to ${strategy.name}`);
3838

3939
if (error instanceof Error) {
@@ -94,7 +94,7 @@ export const validateAuthFormWithFallback = async (request: Request) => {
9494

9595
return result.form;
9696
} catch (error) {
97-
if (import.meta.env.DEV) {
97+
if (isDevelopmentMode()) {
9898
console.warn(`Failed to ${strategy.name}`);
9999

100100
if (error instanceof Error) {
@@ -146,6 +146,14 @@ const formValidationStrategies = [
146146
},
147147
];
148148

149+
/**
150+
* Helper function to validate if we're in development mode
151+
* This can be mocked in tests to control logging behavior
152+
*/
153+
export const isDevelopmentMode = (): boolean => {
154+
return import.meta.env.DEV;
155+
};
156+
149157
/**
150158
* Common form structure for authentication forms
151159
* Contains constraints and shape definitions used across different form strategies

0 commit comments

Comments
 (0)