Skip to content

Commit

Permalink
use WarningAggregator instead of console.warn
Browse files Browse the repository at this point in the history
  • Loading branch information
jey committed Dec 28, 2024
1 parent 379d3bf commit 5627a4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/auth/plugin/__tests__/iosPlugin_openUrlFix.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs/promises';
import path from 'path';
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { WarningAggregator } from '@expo/config-plugins';
import type { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
import {
shouldApplyIosOpenUrlFix,
Expand Down Expand Up @@ -218,10 +219,11 @@ describe('Config Plugin iOS Tests - openUrlFix', () => {
modRawConfig: { name: 'TestName', slug: 'TestSlug' },
};
const props = undefined;
const spy = jest.spyOn(console, 'warn').mockImplementation(() => undefined);
const spy = jest.spyOn(WarningAggregator, 'addWarningIOS');
const result = withOpenUrlFixForAppDelegate({ config, props });
expect(result.modResults.contents).toBe(appDelegate);
expect(spy).toHaveBeenCalledWith(
'@react-native-firebase/auth',
"Skipping iOS openURL fix because no 'openURL' method was found",
);
});
Expand Down
7 changes: 5 additions & 2 deletions packages/auth/plugin/src/ios/openUrlFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
withAppDelegate,
withInfoPlist,
ExportedConfigWithProps,
WarningAggregator,
} from '@expo/config-plugins';
import type { ExpoConfig } from '@expo/config/build/Config.types';
import type { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
Expand Down Expand Up @@ -66,8 +67,10 @@ export function withOpenUrlFixForAppDelegate({
if (props?.ios?.captchaOpenUrlFix === true) {
throw new Error("Failed to apply iOS openURL fix because no 'openURL' method was found");
} else {
// eslint-disable-next-line no-console
console.warn("Skipping iOS openURL fix because no 'openURL' method was found");
WarningAggregator.addWarningIOS(
'@react-native-firebase/auth',
"Skipping iOS openURL fix because no 'openURL' method was found",
);
return config;
}
} else {
Expand Down

0 comments on commit 5627a4f

Please sign in to comment.