@aws-amplify/ui-react-native 1.2.22 → 1.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/lib/Authenticator/Authenticator.js +72 -0
- package/lib/Authenticator/Defaults/ConfirmResetPassword/ConfirmResetPassword.js +43 -0
- package/lib/Authenticator/Defaults/ConfirmResetPassword/index.js +8 -0
- package/lib/Authenticator/Defaults/ConfirmSignIn/ConfirmSignIn.js +42 -0
- package/lib/Authenticator/Defaults/ConfirmSignIn/index.js +8 -0
- package/lib/Authenticator/Defaults/ConfirmSignUp/ConfirmSignUp.js +43 -0
- package/lib/Authenticator/Defaults/ConfirmSignUp/index.js +8 -0
- package/lib/Authenticator/Defaults/ConfirmVerifyUser/ConfirmVerifyUser.js +42 -0
- package/lib/Authenticator/Defaults/ConfirmVerifyUser/index.js +8 -0
- package/lib/Authenticator/Defaults/ForceNewPassword/ForceNewPassword.js +45 -0
- package/lib/Authenticator/Defaults/ForceNewPassword/index.js +8 -0
- package/lib/Authenticator/Defaults/ResetPassword/ResetPassword.js +42 -0
- package/lib/Authenticator/Defaults/ResetPassword/index.js +8 -0
- package/lib/Authenticator/Defaults/SetupTOTP/SetupTOTP.js +52 -0
- package/lib/Authenticator/Defaults/SetupTOTP/index.js +8 -0
- package/lib/Authenticator/Defaults/SetupTOTP/styles.js +8 -0
- package/lib/Authenticator/Defaults/SignIn/SignIn.js +50 -0
- package/lib/Authenticator/Defaults/SignIn/index.js +8 -0
- package/lib/Authenticator/Defaults/SignUp/SignUp.js +48 -0
- package/lib/Authenticator/Defaults/SignUp/index.js +8 -0
- package/lib/Authenticator/Defaults/VerifyUser/VerifyUser.js +33 -0
- package/lib/Authenticator/Defaults/VerifyUser/index.js +8 -0
- package/lib/Authenticator/Defaults/index.js +23 -0
- package/lib/Authenticator/Defaults/types.js +2 -0
- package/lib/Authenticator/common/DefaultContainer/DefaultContainer.js +37 -0
- package/lib/Authenticator/common/DefaultContainer/InnerContainer.js +15 -0
- package/lib/Authenticator/common/DefaultContainer/index.js +10 -0
- package/lib/Authenticator/common/DefaultContainer/styles.js +31 -0
- package/lib/Authenticator/common/DefaultContainer/types.js +2 -0
- package/lib/Authenticator/common/DefaultContent/DefaultContent.js +33 -0
- package/lib/Authenticator/common/DefaultContent/index.js +8 -0
- package/lib/Authenticator/common/DefaultContent/styles.js +54 -0
- package/lib/Authenticator/common/DefaultContent/types.js +2 -0
- package/lib/Authenticator/common/DefaultFooter/DefaultFooter.js +9 -0
- package/lib/Authenticator/common/DefaultFooter/index.js +8 -0
- package/lib/Authenticator/common/DefaultFooter/types.js +2 -0
- package/lib/Authenticator/common/DefaultFormFields/DefaultRadioFormFields.js +28 -0
- package/lib/Authenticator/common/DefaultFormFields/DefaultTextFormFields.js +21 -0
- package/lib/Authenticator/common/DefaultFormFields/Field.js +37 -0
- package/lib/Authenticator/common/DefaultFormFields/FieldErrors.js +17 -0
- package/lib/Authenticator/common/DefaultFormFields/index.js +10 -0
- package/lib/Authenticator/common/DefaultFormFields/types.js +2 -0
- package/lib/Authenticator/common/DefaultHeader/DefaultHeader.js +11 -0
- package/lib/Authenticator/common/DefaultHeader/index.js +8 -0
- package/lib/Authenticator/common/DefaultHeader/types.js +2 -0
- package/lib/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +18 -0
- package/lib/Authenticator/common/FederatedProviderButton/index.js +8 -0
- package/lib/Authenticator/common/FederatedProviderButton/styles.js +21 -0
- package/lib/Authenticator/common/FederatedProviderButton/types.js +2 -0
- package/lib/Authenticator/common/FederatedProviderButtons/FederatedProviderButtons.js +26 -0
- package/lib/Authenticator/common/FederatedProviderButtons/index.js +8 -0
- package/lib/Authenticator/common/FederatedProviderButtons/styles.js +8 -0
- package/lib/Authenticator/common/FederatedProviderButtons/types.js +2 -0
- package/lib/Authenticator/common/index.js +10 -0
- package/lib/Authenticator/hooks/index.js +5 -0
- package/lib/Authenticator/hooks/types.js +2 -0
- package/lib/Authenticator/hooks/useFieldValues/constants.js +11 -0
- package/lib/Authenticator/hooks/useFieldValues/index.js +10 -0
- package/lib/Authenticator/hooks/useFieldValues/types.js +2 -0
- package/lib/Authenticator/hooks/useFieldValues/useFieldValues.js +101 -0
- package/lib/Authenticator/hooks/useFieldValues/utils.js +139 -0
- package/lib/Authenticator/index.js +13 -0
- package/lib/Authenticator/types.js +2 -0
- package/lib/Authenticator/withAuthenticator.js +15 -0
- package/lib/InAppMessaging/components/BannerMessage/BannerMessage.js +20 -0
- package/lib/InAppMessaging/components/BannerMessage/index.js +8 -0
- package/lib/InAppMessaging/components/BannerMessage/styles.js +81 -0
- package/lib/InAppMessaging/components/BannerMessage/types.js +2 -0
- package/lib/InAppMessaging/components/CarouselMessage/CarouselMessage.js +25 -0
- package/lib/InAppMessaging/components/CarouselMessage/CarouselMessageItem.js +22 -0
- package/lib/InAppMessaging/components/CarouselMessage/index.js +8 -0
- package/lib/InAppMessaging/components/CarouselMessage/styles.js +103 -0
- package/lib/InAppMessaging/components/CarouselMessage/types.js +2 -0
- package/lib/InAppMessaging/components/FullScreenMessage/FullScreenMessage.js +22 -0
- package/lib/InAppMessaging/components/FullScreenMessage/index.js +8 -0
- package/lib/InAppMessaging/components/FullScreenMessage/styles.js +91 -0
- package/lib/InAppMessaging/components/FullScreenMessage/types.js +2 -0
- package/lib/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.js +32 -0
- package/lib/InAppMessaging/components/InAppMessageDisplay/handleMessageLinkAction.js +26 -0
- package/lib/InAppMessaging/components/InAppMessageDisplay/index.js +8 -0
- package/lib/InAppMessaging/components/InAppMessageDisplay/types.js +2 -0
- package/lib/InAppMessaging/components/MessageLayout/MessageLayout.js +38 -0
- package/lib/InAppMessaging/components/MessageLayout/index.js +8 -0
- package/lib/InAppMessaging/components/MessageLayout/types.js +2 -0
- package/lib/InAppMessaging/components/MessageWrapper/MessageWrapper.js +24 -0
- package/lib/InAppMessaging/components/MessageWrapper/index.js +8 -0
- package/lib/InAppMessaging/components/MessageWrapper/styles.js +8 -0
- package/lib/InAppMessaging/components/MessageWrapper/types.js +2 -0
- package/lib/InAppMessaging/components/ModalMessage/ModalMessage.js +22 -0
- package/lib/InAppMessaging/components/ModalMessage/index.js +8 -0
- package/lib/InAppMessaging/components/ModalMessage/styles.js +104 -0
- package/lib/InAppMessaging/components/ModalMessage/types.js +2 -0
- package/lib/InAppMessaging/components/index.js +7 -0
- package/lib/InAppMessaging/components/withInAppMessaging/index.js +8 -0
- package/lib/InAppMessaging/components/withInAppMessaging/withInAppMessaging.js +15 -0
- package/lib/InAppMessaging/constants.js +48 -0
- package/lib/InAppMessaging/hooks/index.js +7 -0
- package/lib/InAppMessaging/hooks/useMessageImage/constants.js +21 -0
- package/lib/InAppMessaging/hooks/useMessageImage/index.js +8 -0
- package/lib/InAppMessaging/hooks/useMessageImage/types.js +9 -0
- package/lib/InAppMessaging/hooks/useMessageImage/useMessageImage.js +53 -0
- package/lib/InAppMessaging/hooks/useMessageImage/utils.js +61 -0
- package/lib/InAppMessaging/hooks/useMessageProps/index.js +8 -0
- package/lib/InAppMessaging/hooks/useMessageProps/types.js +2 -0
- package/lib/InAppMessaging/hooks/useMessageProps/useMessageProps.js +52 -0
- package/lib/InAppMessaging/hooks/useMessageProps/utils.js +201 -0
- package/lib/InAppMessaging/index.js +9 -0
- package/lib/assets/icons/amazonLogo.png +0 -0
- package/lib/assets/icons/amazonLogo@2x.png +0 -0
- package/lib/assets/icons/amazonLogo@3x.png +0 -0
- package/lib/assets/icons/appleLogo.png +0 -0
- package/lib/assets/icons/appleLogo@2x.png +0 -0
- package/lib/assets/icons/appleLogo@3x.png +0 -0
- package/lib/assets/icons/checkboxFilled.png +0 -0
- package/lib/assets/icons/checkboxFilled@2x.png +0 -0
- package/lib/assets/icons/checkboxFilled@3x.png +0 -0
- package/lib/assets/icons/checkboxOutline.png +0 -0
- package/lib/assets/icons/checkboxOutline@2x.png +0 -0
- package/lib/assets/icons/checkboxOutline@3x.png +0 -0
- package/lib/assets/icons/close.png +0 -0
- package/lib/assets/icons/close@2x.png +0 -0
- package/lib/assets/icons/close@3x.png +0 -0
- package/lib/assets/icons/copy.png +0 -0
- package/lib/assets/icons/copy@2x.png +0 -0
- package/lib/assets/icons/copy@3x.png +0 -0
- package/lib/assets/icons/error.png +0 -0
- package/lib/assets/icons/error@2x.png +0 -0
- package/lib/assets/icons/error@3x.png +0 -0
- package/lib/assets/icons/facebookLogo.png +0 -0
- package/lib/assets/icons/facebookLogo@2x.png +0 -0
- package/lib/assets/icons/facebookLogo@3x.png +0 -0
- package/lib/assets/icons/googleLogo.png +0 -0
- package/lib/assets/icons/googleLogo@2x.png +0 -0
- package/lib/assets/icons/googleLogo@3x.png +0 -0
- package/lib/assets/icons/index.js +16 -0
- package/lib/assets/icons/index.ts +17 -0
- package/lib/assets/icons/visibilityOff.png +0 -0
- package/lib/assets/icons/visibilityOff@2x.png +0 -0
- package/lib/assets/icons/visibilityOff@3x.png +0 -0
- package/lib/assets/icons/visibilityOn.png +0 -0
- package/lib/assets/icons/visibilityOn@2x.png +0 -0
- package/lib/assets/icons/visibilityOn@3x.png +0 -0
- package/lib/assets/index.js +8 -0
- package/lib/hooks/index.js +9 -0
- package/lib/hooks/useDeprecationWarning/index.js +8 -0
- package/lib/hooks/useDeprecationWarning/useDeprecationWarning.js +13 -0
- package/lib/hooks/useDeviceOrientation/index.js +8 -0
- package/lib/hooks/useDeviceOrientation/useDeviceOrientation.js +37 -0
- package/lib/hooks/usePressableContainerStyles/index.js +5 -0
- package/lib/hooks/usePressableContainerStyles/usePressableContainerStyles.js +19 -0
- package/lib/index.js +14 -0
- package/lib/primitives/Button/Button.js +31 -0
- package/lib/primitives/Button/index.js +8 -0
- package/lib/primitives/Button/styles.js +55 -0
- package/lib/primitives/Button/types.js +2 -0
- package/lib/primitives/Carousel/Carousel.js +63 -0
- package/lib/primitives/Carousel/CarouselPageIndicator.js +14 -0
- package/lib/primitives/Carousel/constants.js +21 -0
- package/lib/primitives/Carousel/index.js +10 -0
- package/lib/primitives/Carousel/styles.js +14 -0
- package/lib/primitives/Carousel/types.js +2 -0
- package/lib/primitives/Checkbox/Checkbox.js +28 -0
- package/lib/primitives/Checkbox/index.js +8 -0
- package/lib/primitives/Checkbox/styles.js +28 -0
- package/lib/primitives/Checkbox/types.js +2 -0
- package/lib/primitives/Divider/Divider.js +22 -0
- package/lib/primitives/Divider/index.js +8 -0
- package/lib/primitives/Divider/styles.js +28 -0
- package/lib/primitives/Divider/types.js +2 -0
- package/lib/primitives/ErrorMessage/ErrorMessage.js +22 -0
- package/lib/primitives/ErrorMessage/index.js +8 -0
- package/lib/primitives/ErrorMessage/styles.js +30 -0
- package/lib/primitives/ErrorMessage/types.js +2 -0
- package/lib/primitives/Heading/Heading.js +15 -0
- package/lib/primitives/Heading/index.js +8 -0
- package/lib/primitives/Heading/styles.js +51 -0
- package/lib/primitives/Heading/types.js +2 -0
- package/lib/primitives/Icon/Icon.js +21 -0
- package/lib/primitives/Icon/constants.js +10 -0
- package/lib/primitives/Icon/index.js +10 -0
- package/lib/primitives/Icon/styles.js +34 -0
- package/lib/primitives/Icon/types.js +2 -0
- package/lib/primitives/IconButton/IconButton.js +26 -0
- package/lib/primitives/IconButton/index.js +8 -0
- package/lib/primitives/IconButton/styles.js +21 -0
- package/lib/primitives/IconButton/types.js +2 -0
- package/lib/primitives/Label/Label.js +16 -0
- package/lib/primitives/Label/index.js +8 -0
- package/lib/primitives/Label/styles.js +45 -0
- package/lib/primitives/Label/types.js +2 -0
- package/lib/primitives/Label/utils.js +25 -0
- package/lib/primitives/PasswordField/PasswordField.js +24 -0
- package/lib/primitives/PasswordField/index.js +8 -0
- package/lib/primitives/PasswordField/styles.js +17 -0
- package/lib/primitives/PasswordField/types.js +2 -0
- package/lib/primitives/PhoneNumberField/PhoneNumberField.js +13 -0
- package/lib/primitives/PhoneNumberField/index.js +8 -0
- package/lib/primitives/PhoneNumberField/styles.js +22 -0
- package/lib/primitives/PhoneNumberField/types.js +2 -0
- package/lib/primitives/Radio/Radio.js +46 -0
- package/lib/primitives/Radio/getRadioDimensions.js +43 -0
- package/lib/primitives/Radio/index.js +8 -0
- package/lib/primitives/Radio/styles.js +68 -0
- package/lib/primitives/Radio/types.js +2 -0
- package/lib/primitives/RadioGroup/RadioGroup.js +55 -0
- package/lib/primitives/RadioGroup/index.js +8 -0
- package/lib/primitives/RadioGroup/styles.js +20 -0
- package/lib/primitives/RadioGroup/types.js +2 -0
- package/lib/primitives/Tabs/Tab.js +27 -0
- package/lib/primitives/Tabs/Tabs.js +29 -0
- package/lib/primitives/Tabs/index.js +10 -0
- package/lib/primitives/Tabs/styles.js +58 -0
- package/lib/primitives/Tabs/types.js +2 -0
- package/lib/primitives/TextField/TextField.js +31 -0
- package/lib/primitives/TextField/index.js +8 -0
- package/lib/primitives/TextField/styles.js +46 -0
- package/lib/primitives/TextField/types.js +2 -0
- package/lib/primitives/index.js +18 -0
- package/lib/theme/ThemeContext.js +9 -0
- package/lib/theme/ThemeProvider.js +12 -0
- package/lib/theme/createTheme.js +113 -0
- package/lib/theme/defaultTheme.js +11 -0
- package/lib/theme/index.js +12 -0
- package/lib/theme/types.js +2 -0
- package/lib/theme/useTheme.js +11 -0
- package/lib/utils/font.js +8 -0
- package/lib/utils/index.js +10 -0
- package/lib/utils/platform.js +21 -0
- package/lib/version.js +4 -0
- package/package.json +20 -11
- package/src/version.ts +1 -1
- package/.eslintrc.js +0 -12
- package/.lintstagedrc.js +0 -6
- package/.turbo/turbo-build.log +0 -3
- package/CHANGELOG.md +0 -332
- package/babel.config.js +0 -3
- package/dist/assets/index.ts +0 -1
- package/jest.config.js +0 -22
- package/jest.setup.js +0 -3
- package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/ConfirmResetPassword.spec.tsx +0 -89
- package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/__snapshots__/ConfirmResetPassword.spec.tsx.snap +0 -1090
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/ConfirmSignIn.spec.tsx +0 -78
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/__snapshots__/ConfirmSignIn.spec.tsx.snap +0 -512
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/ConfirmSignUp.spec.tsx +0 -64
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/__snapshots__/ConfirmSignUp.spec.tsx.snap +0 -528
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/ConfirmVerifyUser.spec.tsx +0 -71
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/__snapshots__/ConfirmVerifyUser.spec.tsx.snap +0 -492
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/ForceNewPassword.spec.tsx +0 -79
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/__snapshots__/ForceNewPassword.spec.tsx.snap +0 -896
- package/src/Authenticator/Defaults/ResetPassword/__tests__/ResetPassword.spec.tsx +0 -78
- package/src/Authenticator/Defaults/ResetPassword/__tests__/__snapshots__/ResetPassword.spec.tsx.snap +0 -512
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/SetupTOTP.spec.tsx +0 -85
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/__snapshots__/SetupTOTP.spec.tsx.snap +0 -602
- package/src/Authenticator/Defaults/SignIn/__tests__/SignIn.spec.tsx +0 -67
- package/src/Authenticator/Defaults/SignIn/__tests__/__snapshots__/SignIn.spec.tsx.snap +0 -1281
- package/src/Authenticator/Defaults/SignUp/__tests__/SignUp.spec.tsx +0 -102
- package/src/Authenticator/Defaults/SignUp/__tests__/__snapshots__/SignUp.spec.tsx.snap +0 -3122
- package/src/Authenticator/Defaults/VerifyUser/__tests__/VerifyUser.spec.tsx +0 -107
- package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap +0 -692
- package/src/Authenticator/__tests__/Authenticator.spec.tsx +0 -131
- package/src/Authenticator/__tests__/__snapshots__/Authenticator.spec.tsx.snap +0 -90
- package/src/Authenticator/__tests__/__snapshots__/withAuthenticator.spec.tsx.snap +0 -68
- package/src/Authenticator/__tests__/withAuthenticator.spec.tsx +0 -73
- package/src/Authenticator/common/DefaultContainer/__tests__/DefaultContainer.spec.tsx +0 -19
- package/src/Authenticator/common/DefaultContainer/__tests__/__snapshots__/DefaultContainer.spec.tsx.snap +0 -83
- package/src/Authenticator/common/DefaultFooter/__tests__/DefaultFooter.spec.tsx +0 -26
- package/src/Authenticator/common/DefaultFooter/__tests__/__snapshots__/DefaultFooter.spec.tsx.snap +0 -40
- package/src/Authenticator/common/DefaultFormFields/__tests__/DefaultFormFields.spec.tsx +0 -15
- package/src/Authenticator/common/DefaultFormFields/__tests__/FieldErrors.spec.tsx +0 -29
- package/src/Authenticator/common/DefaultFormFields/__tests__/__snapshots__/DefaultFormFields.spec.tsx.snap +0 -3
- package/src/Authenticator/common/DefaultFormFields/__tests__/__snapshots__/FieldErrors.spec.tsx.snap +0 -32
- package/src/Authenticator/common/DefaultHeader/__tests__/DefaultHeader.spec.tsx +0 -23
- package/src/Authenticator/common/DefaultHeader/__tests__/__snapshots__/DefaultHeader.spec.tsx.snap +0 -24
- package/src/Authenticator/common/FederatedProviderButton/__tests__/FederatedProviderButton.spec.tsx +0 -67
- package/src/Authenticator/common/FederatedProviderButton/__tests__/__snapshots__/FederatedProviderButton.spec.tsx.snap +0 -185
- package/src/Authenticator/common/FederatedProviderButtons/__tests__/FederatedProviderButtons.spec.tsx +0 -55
- package/src/Authenticator/common/FederatedProviderButtons/__tests__/__snapshots__/FederatedProviderButtons.spec.tsx.snap +0 -167
- package/src/Authenticator/hooks/useFieldValues/__tests__/useFieldValues.spec.ts +0 -399
- package/src/Authenticator/hooks/useFieldValues/__tests__/utils.spec.ts +0 -282
- package/src/InAppMessaging/components/BannerMessage/__tests__/BannerMessage.spec.tsx +0 -151
- package/src/InAppMessaging/components/BannerMessage/__tests__/__snapshots__/BannerMessage.spec.tsx.snap +0 -618
- package/src/InAppMessaging/components/CarouselMessage/__tests__/CarouselMessage.spec.tsx +0 -92
- package/src/InAppMessaging/components/CarouselMessage/__tests__/CarouselMessageItem.spec.tsx +0 -50
- package/src/InAppMessaging/components/CarouselMessage/__tests__/__snapshots__/CarouselMessage.spec.tsx.snap +0 -124
- package/src/InAppMessaging/components/CarouselMessage/__tests__/__snapshots__/CarouselMessageItem.spec.tsx.snap +0 -248
- package/src/InAppMessaging/components/FullScreenMessage/__tests__/FullScreenMessage.spec.tsx +0 -53
- package/src/InAppMessaging/components/FullScreenMessage/__tests__/__snapshots__/FullScreenMessage.spec.tsx.snap +0 -238
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/InAppMessageDisplay.spec.tsx +0 -34
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/__snapshots__/InAppMessageDisplay.spec.tsx.snap +0 -9
- package/src/InAppMessaging/components/InAppMessageDisplay/__tests__/handleMessageLinkAction.spec.ts +0 -51
- package/src/InAppMessaging/components/MessageWrapper/__tests__/MessageWrapper.spec.tsx +0 -19
- package/src/InAppMessaging/components/MessageWrapper/__tests__/__snapshots__/MessageWrapper.spec.tsx.snap +0 -35
- package/src/InAppMessaging/components/ModalMessage/__tests__/ModalMessage.spec.tsx +0 -169
- package/src/InAppMessaging/components/ModalMessage/__tests__/__snapshots__/ModalMessage.spec.tsx.snap +0 -727
- package/src/InAppMessaging/components/withInAppMessaging/__tests__/__snapshots__/withInAppMessaging.spec.tsx.snap +0 -3
- package/src/InAppMessaging/components/withInAppMessaging/__tests__/withInAppMessaging.spec.tsx +0 -15
- package/src/InAppMessaging/hooks/useMessageImage/__tests__/useMessageImage.spec.ts +0 -141
- package/src/InAppMessaging/hooks/useMessageImage/__tests__/utils.spec.ts +0 -107
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/__snapshots__/utils.spec.ts.snap +0 -223
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/useMessageProps.spec.ts +0 -162
- package/src/InAppMessaging/hooks/useMessageProps/__tests__/utils.spec.ts +0 -355
- package/src/__mocks__/@react-native-async-storage/async-storage.ts +0 -2
- package/src/__mocks__/@react-native-community/netinfo.ts +0 -3
- package/src/__mocks__/react-native-safe-area-context.ts +0 -9
- package/src/__tests__/__snapshots__/index.spec.ts.snap +0 -26
- package/src/__tests__/index.spec.ts +0 -8
- package/src/hooks/useDeprecationWarning/__tests__/useDeprecationWarning.spec.ts +0 -42
- package/src/hooks/useDeviceOrientation/__tests__/useDeviceOrientation.spec.ts +0 -89
- package/src/hooks/usePressableContainerStyles/__tests__/usePressableContainerStyles.spec.ts +0 -68
- package/src/primitives/Button/__tests__/Button.spec.tsx +0 -92
- package/src/primitives/Button/__tests__/__snapshots__/Button.spec.tsx.snap +0 -143
- package/src/primitives/Carousel/__tests__/Carousel.spec.tsx +0 -174
- package/src/primitives/Carousel/__tests__/CarouselPageIndicator.spec.tsx +0 -73
- package/src/primitives/Carousel/__tests__/__snapshots__/Carousel.spec.tsx.snap +0 -310
- package/src/primitives/Carousel/__tests__/__snapshots__/CarouselPageIndicator.spec.tsx.snap +0 -191
- package/src/primitives/Checkbox/__tests__/Checkbox.spec.tsx +0 -150
- package/src/primitives/Checkbox/__tests__/__snapshots__/Checkbox.spec.tsx.snap +0 -527
- package/src/primitives/Divider/__tests__/Divider.spec.tsx +0 -50
- package/src/primitives/Divider/__tests__/__snapshots__/Divider.spec.tsx.snap +0 -165
- package/src/primitives/ErrorMessage/__tests__/ErrorMessage.spec.tsx +0 -60
- package/src/primitives/ErrorMessage/__tests__/__snapshots__/ErrorMessage.spec.tsx.snap +0 -123
- package/src/primitives/Heading/__tests__/Heading.spec.tsx +0 -73
- package/src/primitives/Heading/__tests__/__snapshots__/Heading.spec.tsx.snap +0 -171
- package/src/primitives/Icon/__tests__/Icon.spec.tsx +0 -100
- package/src/primitives/Icon/__tests__/__snapshots__/Icon.spec.tsx.snap +0 -139
- package/src/primitives/IconButton/__tests__/IconButton.spec.tsx +0 -71
- package/src/primitives/IconButton/__tests__/__snapshots__/IconButton.spec.tsx.snap +0 -192
- package/src/primitives/Label/__tests__/Label.spec.tsx +0 -75
- package/src/primitives/Label/__tests__/__snapshots__/Label.spec.tsx.snap +0 -91
- package/src/primitives/PasswordField/__tests__/PasswordField.spec.tsx +0 -110
- package/src/primitives/PasswordField/__tests__/__snapshots__/PasswordField.spec.tsx.snap +0 -625
- package/src/primitives/PhoneNumberField/__tests__/PhoneNumberField.spec.tsx +0 -53
- package/src/primitives/PhoneNumberField/__tests__/__snapshots__/PhoneNumberField.spec.tsx.snap +0 -188
- package/src/primitives/Radio/__tests__/Radio.spec.tsx +0 -166
- package/src/primitives/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +0 -678
- package/src/primitives/RadioGroup/__tests__/RadioGroup.spec.tsx +0 -183
- package/src/primitives/RadioGroup/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +0 -1789
- package/src/primitives/Tabs/__tests__/Tab.spec.tsx +0 -75
- package/src/primitives/Tabs/__tests__/Tabs.spec.tsx +0 -81
- package/src/primitives/Tabs/__tests__/__snapshots__/Tab.spec.tsx.snap +0 -278
- package/src/primitives/Tabs/__tests__/__snapshots__/Tabs.spec.tsx.snap +0 -163
- package/src/primitives/TextField/__tests__/TextField.spec.tsx +0 -202
- package/src/primitives/TextField/__tests__/__snapshots__/TextField.spec.tsx.snap +0 -507
- package/src/theme/__tests__/ThemeProvider.spec.tsx +0 -23
- package/src/theme/__tests__/__snapshots__/useTheme.spec.tsx.snap +0 -226
- package/src/theme/__tests__/createTheme.spec.ts +0 -244
- package/src/theme/__tests__/useTheme.spec.tsx +0 -51
- package/tsconfig.dist.json +0 -4
- package/tsconfig.json +0 -9
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
|
-
import { NativeSyntheticEvent, TextInputFocusEventData } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import { Logger } from 'aws-amplify';
|
|
5
|
-
import {
|
|
6
|
-
UnverifiedContactMethodType,
|
|
7
|
-
authenticatorTextUtil,
|
|
8
|
-
} from '@aws-amplify/ui';
|
|
9
|
-
import {
|
|
10
|
-
RadioFieldOptions,
|
|
11
|
-
TextFieldOptionsType,
|
|
12
|
-
TypedField,
|
|
13
|
-
} from '../../types';
|
|
14
|
-
import { UseFieldValuesParams } from '../types';
|
|
15
|
-
import useFieldValues from '../useFieldValues';
|
|
16
|
-
|
|
17
|
-
const warnSpy = jest.spyOn(Logger.prototype, 'warn').mockImplementation();
|
|
18
|
-
|
|
19
|
-
const textField = {
|
|
20
|
-
label: 'test',
|
|
21
|
-
type: 'default',
|
|
22
|
-
name: 'test',
|
|
23
|
-
value: 'testValue',
|
|
24
|
-
} as TextFieldOptionsType;
|
|
25
|
-
|
|
26
|
-
const radioField = {
|
|
27
|
-
type: 'radio',
|
|
28
|
-
name: 'email',
|
|
29
|
-
value: 'testValue',
|
|
30
|
-
onChange: jest.fn,
|
|
31
|
-
} as RadioFieldOptions;
|
|
32
|
-
|
|
33
|
-
const mockfields = [] as TypedField[];
|
|
34
|
-
const props: UseFieldValuesParams<TypedField> = {
|
|
35
|
-
componentName: 'SignIn',
|
|
36
|
-
fields: mockfields,
|
|
37
|
-
handleBlur: jest.fn(),
|
|
38
|
-
handleChange: jest.fn(),
|
|
39
|
-
handleSubmit: jest.fn(),
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
describe('useFieldValues', () => {
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
jest.clearAllMocks();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('returns the expected values for text fields', () => {
|
|
48
|
-
const { result } = renderHook(() =>
|
|
49
|
-
useFieldValues({
|
|
50
|
-
...props,
|
|
51
|
-
fields: [textField],
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
expect(result.current).toStrictEqual({
|
|
55
|
-
disableFormSubmit: false,
|
|
56
|
-
fields: [
|
|
57
|
-
{
|
|
58
|
-
...textField,
|
|
59
|
-
onBlur: expect.any(Function),
|
|
60
|
-
onChangeText: expect.any(Function),
|
|
61
|
-
value: undefined,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
fieldValidationErrors: {},
|
|
65
|
-
handleFormSubmit: expect.any(Function),
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('removes hidden labels from text fields', () => {
|
|
70
|
-
const { result } = renderHook(() =>
|
|
71
|
-
useFieldValues({
|
|
72
|
-
...props,
|
|
73
|
-
fields: [{ ...textField, labelHidden: true }],
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
expect(result.current).toStrictEqual({
|
|
77
|
-
disableFormSubmit: false,
|
|
78
|
-
fields: [
|
|
79
|
-
{
|
|
80
|
-
...textField,
|
|
81
|
-
label: undefined,
|
|
82
|
-
onBlur: expect.any(Function),
|
|
83
|
-
onChangeText: expect.any(Function),
|
|
84
|
-
value: undefined,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
fieldValidationErrors: {},
|
|
88
|
-
handleFormSubmit: expect.any(Function),
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('returns the expected values for radio fields', () => {
|
|
93
|
-
const { result } = renderHook(() =>
|
|
94
|
-
useFieldValues({
|
|
95
|
-
...props,
|
|
96
|
-
componentName: 'VerifyUser',
|
|
97
|
-
fields: [radioField],
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
expect(result.current).toStrictEqual({
|
|
101
|
-
disableFormSubmit: true,
|
|
102
|
-
fields: [{ ...radioField, onChange: expect.any(Function) }],
|
|
103
|
-
fieldValidationErrors: {},
|
|
104
|
-
handleFormSubmit: expect.any(Function),
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('returns the expected values with no fields', () => {
|
|
109
|
-
const { result } = renderHook(() => useFieldValues(props));
|
|
110
|
-
|
|
111
|
-
expect(result.current).toStrictEqual({
|
|
112
|
-
disableFormSubmit: false,
|
|
113
|
-
fields: mockfields,
|
|
114
|
-
fieldValidationErrors: {},
|
|
115
|
-
handleFormSubmit: expect.any(Function),
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('logs a warning for non array fields', () => {
|
|
120
|
-
const mockFields = 'test' as unknown as RadioFieldOptions[];
|
|
121
|
-
renderHook(() => useFieldValues({ ...props, fields: mockFields }));
|
|
122
|
-
|
|
123
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
124
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
125
|
-
`Invalid fields type of ${typeof mockFields} passed to ${
|
|
126
|
-
props.componentName
|
|
127
|
-
}. fields must be of type array.`
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('calls expected handlers for text fields', () => {
|
|
132
|
-
const { result } = renderHook(() =>
|
|
133
|
-
useFieldValues({ ...props, fields: [textField] })
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
const mockEvent = {
|
|
137
|
-
nativeEvent: { target: 1 },
|
|
138
|
-
} as NativeSyntheticEvent<TextInputFocusEventData>;
|
|
139
|
-
act(() => {
|
|
140
|
-
result.current.fields[0].onBlur?.(mockEvent);
|
|
141
|
-
});
|
|
142
|
-
expect(props.handleBlur).toHaveBeenCalledTimes(1);
|
|
143
|
-
expect(props.handleBlur).toHaveBeenCalledWith({
|
|
144
|
-
name: textField.name,
|
|
145
|
-
value: undefined,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
const mockValue = 'test';
|
|
149
|
-
act(() => {
|
|
150
|
-
result.current.fields[0].onChangeText?.(mockValue);
|
|
151
|
-
});
|
|
152
|
-
expect(props.handleChange).toHaveBeenCalledTimes(1);
|
|
153
|
-
expect(props.handleChange).toHaveBeenCalledWith({
|
|
154
|
-
name: textField.name,
|
|
155
|
-
value: mockValue,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
result.current.handleFormSubmit();
|
|
159
|
-
expect(props.handleSubmit).toHaveBeenCalledTimes(1);
|
|
160
|
-
expect(props.handleSubmit).toHaveBeenCalledWith({
|
|
161
|
-
[textField.name]: mockValue,
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('runs validations for email fields', () => {
|
|
166
|
-
const emailField = {
|
|
167
|
-
label: 'test',
|
|
168
|
-
type: 'email',
|
|
169
|
-
name: 'invalid_email',
|
|
170
|
-
value: 'test@',
|
|
171
|
-
} as TextFieldOptionsType;
|
|
172
|
-
const phoneTextField = {
|
|
173
|
-
type: 'phone',
|
|
174
|
-
name: 'testPhone',
|
|
175
|
-
} as TextFieldOptionsType;
|
|
176
|
-
const { result } = renderHook(() =>
|
|
177
|
-
useFieldValues({
|
|
178
|
-
...props,
|
|
179
|
-
fields: [emailField, phoneTextField],
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
const mockEvent = {
|
|
183
|
-
nativeEvent: { target: 1 },
|
|
184
|
-
} as NativeSyntheticEvent<TextInputFocusEventData>;
|
|
185
|
-
act(() => {
|
|
186
|
-
result.current.fields[0].onBlur?.(mockEvent);
|
|
187
|
-
});
|
|
188
|
-
expect(props.handleBlur).toHaveBeenCalledTimes(1);
|
|
189
|
-
expect(props.handleBlur).toHaveBeenCalledWith({
|
|
190
|
-
name: emailField.name,
|
|
191
|
-
value: undefined,
|
|
192
|
-
});
|
|
193
|
-
expect(result.current.fieldValidationErrors).toStrictEqual({
|
|
194
|
-
[emailField.name]: [authenticatorTextUtil.getInvalidEmailText()],
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it('runs validations for required fields', () => {
|
|
199
|
-
const requiredField = {
|
|
200
|
-
label: 'test',
|
|
201
|
-
type: 'password',
|
|
202
|
-
name: 'required',
|
|
203
|
-
required: true,
|
|
204
|
-
} as TextFieldOptionsType;
|
|
205
|
-
const { result } = renderHook(() =>
|
|
206
|
-
useFieldValues({
|
|
207
|
-
...props,
|
|
208
|
-
fields: [requiredField],
|
|
209
|
-
})
|
|
210
|
-
);
|
|
211
|
-
const mockEvent = {
|
|
212
|
-
nativeEvent: { target: 1 },
|
|
213
|
-
} as NativeSyntheticEvent<TextInputFocusEventData>;
|
|
214
|
-
act(() => {
|
|
215
|
-
result.current.fields[0].onBlur?.(mockEvent);
|
|
216
|
-
});
|
|
217
|
-
expect(props.handleBlur).toHaveBeenCalledTimes(1);
|
|
218
|
-
expect(props.handleBlur).toHaveBeenCalledWith({
|
|
219
|
-
name: requiredField.name,
|
|
220
|
-
value: undefined,
|
|
221
|
-
});
|
|
222
|
-
expect(result.current.fieldValidationErrors).toStrictEqual({
|
|
223
|
-
[requiredField.name]: [authenticatorTextUtil.getRequiredFieldText()],
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('calls expected handlers for radios', () => {
|
|
228
|
-
const { result } = renderHook(() =>
|
|
229
|
-
useFieldValues({
|
|
230
|
-
...props,
|
|
231
|
-
componentName: 'VerifyUser',
|
|
232
|
-
fields: [radioField],
|
|
233
|
-
})
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
const mockValue = 'test';
|
|
237
|
-
act(() => {
|
|
238
|
-
result.current.fields[0].onChange?.(mockValue);
|
|
239
|
-
});
|
|
240
|
-
expect(result.current.fields[0].value).toEqual(radioField.value);
|
|
241
|
-
|
|
242
|
-
result.current.handleFormSubmit();
|
|
243
|
-
expect(props.handleSubmit).toHaveBeenCalledTimes(1);
|
|
244
|
-
expect(props.handleSubmit).toHaveBeenCalledWith({
|
|
245
|
-
unverifiedAttr: mockValue,
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('restricts radio fields to unverified contact methods', () => {
|
|
250
|
-
const phoneRadioField = {
|
|
251
|
-
type: 'radio',
|
|
252
|
-
name: 'phone_number',
|
|
253
|
-
value: 'testValue',
|
|
254
|
-
onChange: jest.fn,
|
|
255
|
-
} as RadioFieldOptions;
|
|
256
|
-
const unsupportedRadioField = {
|
|
257
|
-
type: 'radio',
|
|
258
|
-
name: 'test',
|
|
259
|
-
value: 'testUnsupportedValue',
|
|
260
|
-
onChange: jest.fn,
|
|
261
|
-
} as RadioFieldOptions;
|
|
262
|
-
|
|
263
|
-
const { result } = renderHook(() =>
|
|
264
|
-
useFieldValues({
|
|
265
|
-
...props,
|
|
266
|
-
componentName: 'VerifyUser',
|
|
267
|
-
fields: [phoneRadioField, unsupportedRadioField],
|
|
268
|
-
})
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
expect(result.current.fields.length).toBe(1);
|
|
272
|
-
expect(result.current.fields[0].value).toEqual(phoneRadioField.value);
|
|
273
|
-
|
|
274
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
275
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
276
|
-
`field with name '${
|
|
277
|
-
unsupportedRadioField.name
|
|
278
|
-
}' has been ignored. Supported values are: ${Object.values(
|
|
279
|
-
UnverifiedContactMethodType
|
|
280
|
-
)}.`
|
|
281
|
-
);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it("disables form submit if required fields don't have values", () => {
|
|
285
|
-
const mockTextField = {
|
|
286
|
-
type: 'default',
|
|
287
|
-
name: 'test',
|
|
288
|
-
required: true,
|
|
289
|
-
} as TextFieldOptionsType;
|
|
290
|
-
const { result } = renderHook(() =>
|
|
291
|
-
useFieldValues({
|
|
292
|
-
...props,
|
|
293
|
-
fields: [mockTextField],
|
|
294
|
-
})
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
expect(result.current).toStrictEqual({
|
|
298
|
-
disableFormSubmit: true,
|
|
299
|
-
fields: [
|
|
300
|
-
{
|
|
301
|
-
...mockTextField,
|
|
302
|
-
label: undefined,
|
|
303
|
-
onBlur: expect.any(Function),
|
|
304
|
-
onChangeText: expect.any(Function),
|
|
305
|
-
value: undefined,
|
|
306
|
-
},
|
|
307
|
-
],
|
|
308
|
-
fieldValidationErrors: {},
|
|
309
|
-
handleFormSubmit: expect.any(Function),
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it('enables form submit if required fields have values', () => {
|
|
314
|
-
const mockTextField = {
|
|
315
|
-
label: 'test',
|
|
316
|
-
type: 'default',
|
|
317
|
-
name: 'test',
|
|
318
|
-
required: true,
|
|
319
|
-
} as TextFieldOptionsType;
|
|
320
|
-
const { result } = renderHook(() =>
|
|
321
|
-
useFieldValues({
|
|
322
|
-
...props,
|
|
323
|
-
fields: [mockTextField],
|
|
324
|
-
})
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
const mockValue = 'test';
|
|
328
|
-
act(() => {
|
|
329
|
-
result.current.fields[0].onChangeText?.(mockValue);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
expect(result.current).toStrictEqual({
|
|
333
|
-
disableFormSubmit: false,
|
|
334
|
-
fields: [
|
|
335
|
-
{
|
|
336
|
-
...mockTextField,
|
|
337
|
-
onBlur: expect.any(Function),
|
|
338
|
-
onChangeText: expect.any(Function),
|
|
339
|
-
value: mockValue,
|
|
340
|
-
},
|
|
341
|
-
],
|
|
342
|
-
fieldValidationErrors: {},
|
|
343
|
-
handleFormSubmit: expect.any(Function),
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it('does not submit undefined values for fields', () => {
|
|
348
|
-
const textField = {
|
|
349
|
-
label: 'test',
|
|
350
|
-
type: 'default',
|
|
351
|
-
name: 'testDefault',
|
|
352
|
-
} as TextFieldOptionsType;
|
|
353
|
-
const phoneTextField = {
|
|
354
|
-
type: 'phone',
|
|
355
|
-
name: 'testPhone',
|
|
356
|
-
} as TextFieldOptionsType;
|
|
357
|
-
const { result } = renderHook(() =>
|
|
358
|
-
useFieldValues({
|
|
359
|
-
...props,
|
|
360
|
-
fields: [textField, phoneTextField],
|
|
361
|
-
})
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
result.current.handleFormSubmit();
|
|
365
|
-
expect(props.handleSubmit).toHaveBeenCalledTimes(1);
|
|
366
|
-
expect(props.handleSubmit).toHaveBeenCalledWith({
|
|
367
|
-
country_code: '',
|
|
368
|
-
[textField.name]: '',
|
|
369
|
-
[phoneTextField.name]: '',
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
it('submits the expected values for phone fields', () => {
|
|
374
|
-
const phoneTextField = {
|
|
375
|
-
type: 'phone',
|
|
376
|
-
name: 'test',
|
|
377
|
-
} as TextFieldOptionsType;
|
|
378
|
-
const { result } = renderHook(() =>
|
|
379
|
-
useFieldValues({
|
|
380
|
-
...props,
|
|
381
|
-
fields: [phoneTextField],
|
|
382
|
-
})
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
const mockValue = '+10000000000';
|
|
386
|
-
act(() => {
|
|
387
|
-
result.current.fields[0].onChangeText?.(mockValue);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
expect(result.current.fields.length).toBe(1);
|
|
391
|
-
expect(result.current.fields[0].value).toEqual(mockValue);
|
|
392
|
-
result.current.handleFormSubmit();
|
|
393
|
-
expect(props.handleSubmit).toHaveBeenCalledTimes(1);
|
|
394
|
-
expect(props.handleSubmit).toHaveBeenCalledWith({
|
|
395
|
-
country_code: mockValue.substring(0, 3),
|
|
396
|
-
[phoneTextField.name]: mockValue.substring(3, mockValue.length),
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
});
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { Logger } from 'aws-amplify';
|
|
2
|
-
import { authenticatorTextUtil } from '@aws-amplify/ui';
|
|
3
|
-
|
|
4
|
-
import { TextFieldOptionsType, TypedField } from '../../types';
|
|
5
|
-
import {
|
|
6
|
-
getRouteTypedFields,
|
|
7
|
-
getSanitizedRadioFields,
|
|
8
|
-
getSanitizedTextFields,
|
|
9
|
-
runFieldValidation,
|
|
10
|
-
} from '../utils';
|
|
11
|
-
|
|
12
|
-
const warnSpy = jest.spyOn(Logger.prototype, 'warn');
|
|
13
|
-
|
|
14
|
-
const idle = 'idle';
|
|
15
|
-
const signIn = 'signIn';
|
|
16
|
-
const verifyUser = 'verifyUser';
|
|
17
|
-
|
|
18
|
-
const passwordField = {
|
|
19
|
-
type: 'password',
|
|
20
|
-
name: 'password',
|
|
21
|
-
label: 'Password',
|
|
22
|
-
required: true,
|
|
23
|
-
};
|
|
24
|
-
const phoneField = {
|
|
25
|
-
name: 'phonenumber',
|
|
26
|
-
type: 'tel',
|
|
27
|
-
};
|
|
28
|
-
const textField = {
|
|
29
|
-
order: 3,
|
|
30
|
-
name: 'username',
|
|
31
|
-
isRequired: true,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const radioField = { type: 'radio', name: 'email', value: 'hello@world.com' };
|
|
35
|
-
|
|
36
|
-
describe('getSanitizedTextFields', () => {
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
jest.resetAllMocks();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('returns the expected values in the happy path', () => {
|
|
42
|
-
const fields: TypedField[] = [{ name: 'test', type: 'default' }];
|
|
43
|
-
const output = getSanitizedTextFields(fields, 'SignIn');
|
|
44
|
-
|
|
45
|
-
expect(output).toHaveLength(1);
|
|
46
|
-
expect(output).toStrictEqual(fields);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('logs a warning and ignores the field when name is missing', () => {
|
|
50
|
-
const validField: TypedField = { name: 'test', type: 'default' };
|
|
51
|
-
const fields: TypedField[] = [
|
|
52
|
-
validField,
|
|
53
|
-
{ type: 'password', label: 'Password' } as TypedField,
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
const output = getSanitizedTextFields(fields, 'SignIn');
|
|
57
|
-
|
|
58
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
59
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
60
|
-
'Each field must have a name. field has been ignored.'
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect(output).toHaveLength(1);
|
|
64
|
-
expect(output).toStrictEqual([validField]);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('logs a warning and ignores the field when type is radio', () => {
|
|
68
|
-
const validField: TypedField = { name: 'test', type: 'default' };
|
|
69
|
-
const fields: TypedField[] = [
|
|
70
|
-
validField,
|
|
71
|
-
{ name: 'Phone Number', type: 'radio', value: 'value' },
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
const output = getSanitizedTextFields(fields, 'SignIn');
|
|
75
|
-
|
|
76
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
77
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
78
|
-
'SignIn component does not support radio fields. field has been ignored.'
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
expect(output).toHaveLength(1);
|
|
82
|
-
expect(output).toStrictEqual([validField]);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('logs a warning and ignores the field when name is a duplicate', () => {
|
|
86
|
-
const validField: TypedField = { name: 'test', type: 'default' };
|
|
87
|
-
const fields: TypedField[] = [
|
|
88
|
-
validField,
|
|
89
|
-
{ name: 'test', type: 'password' },
|
|
90
|
-
];
|
|
91
|
-
|
|
92
|
-
const output = getSanitizedTextFields(fields, 'SignIn');
|
|
93
|
-
|
|
94
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
95
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
96
|
-
'Each field name must be unique. field with duplicate name of test has been ignored.'
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
expect(output).toHaveLength(1);
|
|
100
|
-
expect(output).toStrictEqual([validField]);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe('getSanitizedRadioFields', () => {
|
|
105
|
-
afterEach(() => {
|
|
106
|
-
jest.resetAllMocks();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('logs a warning and ignores the field when not a radio field', () => {
|
|
110
|
-
const validField: TypedField = {
|
|
111
|
-
name: 'email',
|
|
112
|
-
type: 'radio',
|
|
113
|
-
value: 'value',
|
|
114
|
-
};
|
|
115
|
-
const fields: TypedField[] = [
|
|
116
|
-
validField,
|
|
117
|
-
{ type: 'password', value: 'value' } as TypedField,
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
const output = getSanitizedRadioFields(fields, 'VerifyUser');
|
|
121
|
-
|
|
122
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
123
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
124
|
-
'VerifyUser component does not support text fields. field with type password has been ignored.'
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
expect(output).toHaveLength(1);
|
|
128
|
-
expect(output).toStrictEqual([validField]);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('logs a warning and ignores the field when value is missing.', () => {
|
|
132
|
-
const validField: TypedField = {
|
|
133
|
-
name: 'email',
|
|
134
|
-
type: 'radio',
|
|
135
|
-
value: 'value',
|
|
136
|
-
};
|
|
137
|
-
const fields: TypedField[] = [
|
|
138
|
-
validField,
|
|
139
|
-
{ name: 'phone_number', type: 'radio' } as TypedField,
|
|
140
|
-
];
|
|
141
|
-
|
|
142
|
-
const output = getSanitizedRadioFields(fields, 'VerifyUser');
|
|
143
|
-
|
|
144
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
145
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
146
|
-
'Each radio field must have a value. field has been ignored.'
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
expect(output).toHaveLength(1);
|
|
150
|
-
expect(output).toStrictEqual([validField]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('logs a warning and ignores the field when a duplicate value is found.', () => {
|
|
154
|
-
const validField: TypedField = {
|
|
155
|
-
name: 'email',
|
|
156
|
-
type: 'radio',
|
|
157
|
-
value: 'testValue',
|
|
158
|
-
};
|
|
159
|
-
const fields: TypedField[] = [
|
|
160
|
-
validField,
|
|
161
|
-
{ name: 'email', type: 'radio', value: 'testValue' } as TypedField,
|
|
162
|
-
];
|
|
163
|
-
|
|
164
|
-
const output = getSanitizedRadioFields(fields, 'VerifyUser');
|
|
165
|
-
|
|
166
|
-
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
167
|
-
expect(warnSpy).toHaveBeenCalledWith(
|
|
168
|
-
'Each radio field value must be unique. field with duplicate value of testValue has been ignored.'
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
expect(output).toHaveLength(1);
|
|
172
|
-
expect(output).toStrictEqual([validField]);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe('getRouteTypedFields', () => {
|
|
177
|
-
it('returns the expected value for a non-component route', () => {
|
|
178
|
-
const fields = getRouteTypedFields({ fields: [], route: idle });
|
|
179
|
-
|
|
180
|
-
expect(fields).toStrictEqual([]);
|
|
181
|
-
expect(fields).toHaveLength(0);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('returns the expected result for the verifyUser route', () => {
|
|
185
|
-
const fields = getRouteTypedFields({
|
|
186
|
-
fields: [radioField],
|
|
187
|
-
route: verifyUser,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
expect(fields).toStrictEqual([radioField]);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('returns the expected value for varied fields', () => {
|
|
194
|
-
const fields = getRouteTypedFields({
|
|
195
|
-
fields: [passwordField, phoneField, textField],
|
|
196
|
-
route: signIn,
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
const expected = [
|
|
200
|
-
{
|
|
201
|
-
...passwordField,
|
|
202
|
-
testID: `authenticator__text-field__input-${passwordField.name}`,
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
name: phoneField.name,
|
|
206
|
-
type: 'phone',
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
name: textField.name,
|
|
210
|
-
required: textField.isRequired,
|
|
211
|
-
type: 'default',
|
|
212
|
-
testID: `authenticator__text-field__input-${textField.name}`,
|
|
213
|
-
},
|
|
214
|
-
];
|
|
215
|
-
|
|
216
|
-
expect(fields).toStrictEqual(expected);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe('runFieldValidation', () => {
|
|
221
|
-
const { getInvalidEmailText, getRequiredFieldText } = authenticatorTextUtil;
|
|
222
|
-
const field: TextFieldOptionsType = {
|
|
223
|
-
required: true,
|
|
224
|
-
type: 'email',
|
|
225
|
-
name: 'email',
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
it('should return an empty array when no errors are found', () => {
|
|
229
|
-
const value = 'test@example.com';
|
|
230
|
-
const stateValidations = {};
|
|
231
|
-
|
|
232
|
-
const result = runFieldValidation(field, value, stateValidations);
|
|
233
|
-
|
|
234
|
-
expect(result).toEqual([]);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('should return an array with the required field error when value is missing', () => {
|
|
238
|
-
const value = undefined;
|
|
239
|
-
const stateValidations = {};
|
|
240
|
-
|
|
241
|
-
const result = runFieldValidation(field, value, stateValidations);
|
|
242
|
-
|
|
243
|
-
expect(result).toEqual([getRequiredFieldText(), getInvalidEmailText()]);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('should return an array with the invalid email error when email value is invalid', () => {
|
|
247
|
-
const value = 'invalid-email';
|
|
248
|
-
const stateValidations = {};
|
|
249
|
-
|
|
250
|
-
const result = runFieldValidation(field, value, stateValidations);
|
|
251
|
-
|
|
252
|
-
expect(result).toEqual([getInvalidEmailText()]);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('should include state machine validation errors in the result', () => {
|
|
256
|
-
const value = 'test@example.com';
|
|
257
|
-
const errorMessage = 'Email already exists.';
|
|
258
|
-
const stateValidations = {
|
|
259
|
-
email: errorMessage,
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
const result = runFieldValidation(field, value, stateValidations);
|
|
263
|
-
|
|
264
|
-
expect(result).toEqual([errorMessage]);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('should concatenate state machine validation errors with other errors', () => {
|
|
268
|
-
const value = undefined;
|
|
269
|
-
const errorMessage = 'Email already exists.';
|
|
270
|
-
const stateValidations = {
|
|
271
|
-
email: errorMessage,
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
const result = runFieldValidation(field, value, stateValidations);
|
|
275
|
-
|
|
276
|
-
expect(result).toEqual([
|
|
277
|
-
getRequiredFieldText(),
|
|
278
|
-
getInvalidEmailText(),
|
|
279
|
-
errorMessage,
|
|
280
|
-
]);
|
|
281
|
-
});
|
|
282
|
-
});
|