Skip to content

Commit 2588c4d

Browse files
jzabalaljharb
authored andcommitted
[Tests] prop-types: add test
Closes #2747
1 parent 6612375 commit 2588c4d

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/lib/rules/prop-types.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,6 +2898,73 @@ ruleTester.run('prop-types', rule, {
28982898
) => (<div />)
28992899
`,
29002900
parser: parsers['@TYPESCRIPT_ESLINT']
2901+
},
2902+
{
2903+
code: `
2904+
interface Props extends V2SocialLoginProps {
2905+
autoLoad: boolean;
2906+
}
2907+
2908+
export const DKFacebookButton = ({
2909+
autoLoad,
2910+
authAction,
2911+
errorHandler,
2912+
redirectUrl,
2913+
isSignup,
2914+
}: Props): JSX.Element | null => {
2915+
if (!APP_ID) {
2916+
rollbar.error('Missing Facebook OAuth App Id');
2917+
return null;
2918+
}
2919+
2920+
const fbButtonText = isSignup ? 'Sign up with Facebook' : 'Log in with Facebook';
2921+
2922+
const responseCallback = async ({
2923+
accessToken,
2924+
email = '',
2925+
name = '',
2926+
}: ReactFacebookLoginInfo) => {
2927+
const [firstName, lastName] = name.split(' ');
2928+
2929+
const requestData: DK.SocialLogin = {
2930+
accessToken,
2931+
email,
2932+
firstName,
2933+
lastName,
2934+
intercomUserId: intercomService.getVisitorId(),
2935+
};
2936+
2937+
try {
2938+
await authAction(requestData, redirectUrl);
2939+
} catch (err) {
2940+
errorHandler(err.message);
2941+
}
2942+
};
2943+
2944+
const FacebookIcon = () => (
2945+
<img
2946+
style={{ marginRight: '8px' }}
2947+
src={facebookIcon}
2948+
alt='Facebook Login'
2949+
/>
2950+
);
2951+
2952+
return (
2953+
<FacebookLogin
2954+
cssClass='ant-btn dk-button dk-facebook-button dk-button--secondary ant-btn-primary ant-btn-lg'
2955+
autoLoad={autoLoad}
2956+
textButton={fbButtonText}
2957+
size='small'
2958+
icon={<FacebookIcon />}
2959+
appId={APP_ID}
2960+
fields='name,email'
2961+
callback={responseCallback}
2962+
data-testId='dk-facebook-button'
2963+
/>
2964+
);
2965+
};
2966+
`,
2967+
parser: parsers['@TYPESCRIPT_ESLINT']
29012968
}
29022969
])
29032970
),

0 commit comments

Comments
 (0)