@ledgerhq/lumen-ui-rnative 0.1.64 → 0.1.66
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/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/Components/core/AddressInput/AddressInput.js +1 -1
- package/dist/module/lib/Components/core/AddressInput/AddressInput.js.map +1 -1
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js +1 -1
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/core/AmountInput/AmountInput.js +1 -1
- package/dist/module/lib/Components/core/AmountInput/AmountInput.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.js +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.js.map +1 -1
- package/dist/module/lib/Components/core/Banner/Banner.js +1 -1
- package/dist/module/lib/Components/core/Banner/Banner.js.map +1 -1
- package/dist/module/lib/Components/core/BottomSheet/BottomSheetHeader.js +1 -1
- package/dist/module/lib/Components/core/BottomSheet/BottomSheetHeader.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.js +2 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.mdx +4 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js +1 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/ContentBanner/ContentBanner.js +1 -1
- package/dist/module/lib/Components/core/ContentBanner/ContentBanner.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.figma.js +2 -1
- package/dist/module/lib/Components/core/Link/Link.figma.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.js +5 -3
- package/dist/module/lib/Components/core/Link/Link.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.mdx +3 -2
- package/dist/module/lib/Components/core/Link/Link.stories.js +4 -1
- package/dist/module/lib/Components/core/Link/Link.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.test.js +2 -2
- package/dist/module/lib/Components/core/Link/Link.test.js.map +1 -1
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.js +1 -1
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.js.map +1 -1
- package/dist/module/lib/Components/core/MediaCard/MediaCard.js +1 -1
- package/dist/module/lib/Components/core/MediaCard/MediaCard.js.map +1 -1
- package/dist/module/lib/Components/core/NavBar/NavBar.js +1 -1
- package/dist/module/lib/Components/core/NavBar/NavBar.js.map +1 -1
- package/dist/module/lib/Components/core/Spinner/Spinner.js +1 -1
- package/dist/module/lib/Components/core/Spinner/Spinner.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.js +77 -31
- package/dist/module/lib/Components/core/Stepper/Stepper.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.mdx +37 -16
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js +102 -2
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.test.js +32 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.test.js.map +1 -1
- package/dist/module/lib/Components/core/Subheader/Subheader.js +5 -1
- package/dist/module/lib/Components/core/Subheader/Subheader.js.map +1 -1
- package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.js +2 -2
- package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.test.js +9 -0
- package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.test.js.map +1 -1
- package/dist/module/lib/Components/core/Timeline/Timeline.figma.js +83 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.js +464 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.mdx +49 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js +289 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js +234 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/index.js +5 -0
- package/dist/module/lib/Components/core/Timeline/index.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/types.js +4 -0
- package/dist/module/lib/Components/core/Timeline/types.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.figma.js +39 -0
- package/dist/module/lib/Components/core/Toast/Toast.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.js +138 -0
- package/dist/module/lib/Components/core/Toast/Toast.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.mdx +203 -0
- package/dist/module/lib/Components/core/Toast/Toast.stories.js +238 -0
- package/dist/module/lib/Components/core/Toast/Toast.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.test.js +203 -0
- package/dist/module/lib/Components/core/Toast/Toast.test.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toaster.js +147 -0
- package/dist/module/lib/Components/core/Toast/Toaster.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toaster.test.js +732 -0
- package/dist/module/lib/Components/core/Toast/Toaster.test.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js +70 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js +33 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js +224 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js +82 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js +21 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/index.js +7 -0
- package/dist/module/lib/Components/core/Toast/index.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/types.js +4 -0
- package/dist/module/lib/Components/core/Toast/types.js.map +1 -0
- package/dist/module/lib/Components/core/Trend/Trend.js +1 -1
- package/dist/module/lib/Components/core/Trend/Trend.js.map +1 -1
- package/dist/module/lib/Components/core/index.js +2 -0
- package/dist/module/lib/Components/core/index.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseInput/BaseInput.js +1 -1
- package/dist/module/lib/Components/internal/BaseInput/BaseInput.js.map +1 -1
- package/dist/module/lib/Components/visualization/CartesianChart/CartesianChart.js +6 -2
- package/dist/module/lib/Components/visualization/CartesianChart/CartesianChart.js.map +1 -1
- package/dist/module/lib/Components/visualization/DonutChart/DonutChart.js +8 -4
- package/dist/module/lib/Components/visualization/DonutChart/DonutChart.js.map +1 -1
- package/dist/module/lib/Components/visualization/DonutChart/DonutChart.test.js +1 -1
- package/dist/module/lib/Components/visualization/DonutChart/DonutChart.test.js.map +1 -1
- package/dist/module/lib/Components/visualization/DonutChart/DonutRing.js +12 -3
- package/dist/module/lib/Components/visualization/DonutChart/DonutRing.js.map +1 -1
- package/dist/module/lib/Components/visualization/Legend/Legend.js +1 -1
- package/dist/module/lib/Components/visualization/Legend/Legend.js.map +1 -1
- package/dist/module/lib/Components/visualization/Legend/Legend.test.js +12 -8
- package/dist/module/lib/Components/visualization/Legend/Legend.test.js.map +1 -1
- package/dist/module/lib/Components/visualization/LineChart/LineChart.js +8 -2
- package/dist/module/lib/Components/visualization/LineChart/LineChart.js.map +1 -1
- package/dist/module/lib/Components/visualization/LineChart/utils.js +3 -2
- package/dist/module/lib/Components/visualization/LineChart/utils.js.map +1 -1
- package/dist/module/lib/Components/visualization/LineChart/utils.test.js +8 -4
- package/dist/module/lib/Components/visualization/LineChart/utils.test.js.map +1 -1
- package/dist/module/lib/Components/visualization/config.js +1 -4
- package/dist/module/lib/Components/visualization/config.js.map +1 -1
- package/dist/module/translations/index.js +5 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/{i18n → translations}/languages.js +0 -6
- package/dist/module/translations/languages.js.map +1 -0
- package/dist/module/{i18n → translations}/locales/de.json +0 -3
- package/{src/i18n → dist/module/translations}/locales/en.json +9 -3
- package/{src/i18n → dist/module/translations}/locales/es.json +0 -3
- package/dist/module/{i18n → translations}/locales/fr.json +0 -3
- package/{src/i18n → dist/module/translations}/locales/ja.json +0 -3
- package/dist/module/{i18n → translations}/locales/ko.json +0 -3
- package/dist/module/{i18n → translations}/locales/pt.json +0 -3
- package/dist/module/{i18n → translations}/locales/ru.json +0 -3
- package/dist/module/{i18n → translations}/locales/th.json +0 -3
- package/dist/module/{i18n → translations}/locales/tr.json +0 -3
- package/{src/i18n → dist/module/translations}/locales/zh.json +0 -3
- package/dist/module/translations/translations.js +36 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/module/translations/translations.test.js +34 -0
- package/dist/module/translations/translations.test.js.map +1 -0
- package/dist/typescript/src/index.d.ts +1 -1
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts +2 -0
- package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts +4 -3
- package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts +12 -2
- package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Subheader/Subheader.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/ThemeProvider/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/ThemeProvider/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts +56 -0
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts +109 -0
- package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts +24 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts +35 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts +17 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts +19 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts +14 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts +15 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts +21 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/index.d.ts +5 -0
- package/dist/typescript/src/lib/Components/core/Toast/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/types.d.ts +75 -0
- package/dist/typescript/src/lib/Components/core/Toast/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts +2 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/CartesianChart/CartesianChart.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/CartesianChart/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/DonutChart/DonutChart.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/DonutChart/DonutRing.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/DonutChart/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/Legend/Legend.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/Legend/types.d.ts +2 -2
- package/dist/typescript/src/lib/Components/visualization/LineChart/LineChart.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/LineChart/LineChart.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/LineChart/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/visualization/LineChart/utils.d.ts +2 -1
- package/dist/typescript/src/lib/Components/visualization/LineChart/utils.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/visualization/config.d.ts +0 -3
- package/dist/typescript/src/lib/Components/visualization/config.d.ts.map +1 -1
- package/dist/typescript/src/translations/index.d.ts +3 -0
- package/dist/typescript/src/translations/index.d.ts.map +1 -0
- package/dist/typescript/src/{i18n → translations}/languages.d.ts +0 -5
- package/dist/typescript/src/translations/languages.d.ts.map +1 -0
- package/dist/typescript/src/translations/translations.d.ts +421 -0
- package/dist/typescript/src/translations/translations.d.ts.map +1 -0
- package/package.json +4 -6
- package/src/index.ts +1 -1
- package/src/lib/Components/core/AddressInput/AddressInput.tsx +1 -1
- package/src/lib/Components/core/AmountDisplay/AmountDisplay.tsx +1 -1
- package/src/lib/Components/core/AmountInput/AmountInput.tsx +1 -1
- package/src/lib/Components/core/Avatar/Avatar.tsx +1 -1
- package/src/lib/Components/core/Banner/Banner.tsx +1 -1
- package/src/lib/Components/core/BottomSheet/BottomSheetHeader.tsx +1 -1
- package/src/lib/Components/core/CardButton/CardButton.mdx +4 -0
- package/src/lib/Components/core/CardButton/CardButton.stories.tsx +1 -0
- package/src/lib/Components/core/CardButton/CardButton.tsx +2 -0
- package/src/lib/Components/core/ContentBanner/ContentBanner.tsx +1 -1
- package/src/lib/Components/core/Link/Link.figma.tsx +1 -0
- package/src/lib/Components/core/Link/Link.mdx +3 -2
- package/src/lib/Components/core/Link/Link.stories.tsx +3 -2
- package/src/lib/Components/core/Link/Link.test.tsx +2 -0
- package/src/lib/Components/core/Link/Link.tsx +3 -1
- package/src/lib/Components/core/Link/types.ts +1 -1
- package/src/lib/Components/core/MediaBanner/MediaBanner.tsx +1 -1
- package/src/lib/Components/core/MediaCard/MediaCard.tsx +1 -1
- package/src/lib/Components/core/NavBar/NavBar.tsx +1 -1
- package/src/lib/Components/core/Spinner/Spinner.tsx +1 -1
- package/src/lib/Components/core/Stepper/Stepper.mdx +37 -16
- package/src/lib/Components/core/Stepper/Stepper.stories.tsx +50 -2
- package/src/lib/Components/core/Stepper/Stepper.test.tsx +29 -1
- package/src/lib/Components/core/Stepper/Stepper.tsx +74 -33
- package/src/lib/Components/core/Stepper/types.ts +12 -2
- package/src/lib/Components/core/Subheader/Subheader.tsx +3 -1
- package/src/lib/Components/core/ThemeProvider/ThemeProvider.test.tsx +11 -0
- package/src/lib/Components/core/ThemeProvider/ThemeProvider.tsx +3 -3
- package/src/lib/Components/core/ThemeProvider/types.ts +1 -1
- package/src/lib/Components/core/Timeline/Timeline.figma.tsx +79 -0
- package/src/lib/Components/core/Timeline/Timeline.mdx +49 -0
- package/src/lib/Components/core/Timeline/Timeline.stories.tsx +250 -0
- package/src/lib/Components/core/Timeline/Timeline.test.tsx +275 -0
- package/src/lib/Components/core/Timeline/Timeline.tsx +576 -0
- package/src/lib/Components/core/Timeline/index.ts +2 -0
- package/src/lib/Components/core/Timeline/types.ts +124 -0
- package/src/lib/Components/core/Toast/Toast.figma.tsx +36 -0
- package/src/lib/Components/core/Toast/Toast.mdx +203 -0
- package/src/lib/Components/core/Toast/Toast.stories.tsx +260 -0
- package/src/lib/Components/core/Toast/Toast.test.tsx +181 -0
- package/src/lib/Components/core/Toast/Toast.tsx +163 -0
- package/src/lib/Components/core/Toast/Toaster.test.tsx +687 -0
- package/src/lib/Components/core/Toast/Toaster.tsx +157 -0
- package/src/lib/Components/core/Toast/hooks/useToastAccessibility.ts +82 -0
- package/src/lib/Components/core/Toast/hooks/useToastCollapse.ts +38 -0
- package/src/lib/Components/core/Toast/hooks/useToastGesture.ts +83 -0
- package/src/lib/Components/core/Toast/hooks/useToastMotion.ts +71 -0
- package/src/lib/Components/core/Toast/hooks/useToastViewportStyles.ts +45 -0
- package/src/lib/Components/core/Toast/index.ts +4 -0
- package/src/lib/Components/core/Toast/types.ts +94 -0
- package/src/lib/Components/core/Trend/Trend.tsx +1 -1
- package/src/lib/Components/core/index.ts +2 -0
- package/src/lib/Components/internal/BaseInput/BaseInput.tsx +1 -1
- package/src/lib/Components/visualization/CartesianChart/CartesianChart.tsx +4 -2
- package/src/lib/Components/visualization/CartesianChart/types.ts +1 -1
- package/src/lib/Components/visualization/DonutChart/DonutChart.test.tsx +1 -3
- package/src/lib/Components/visualization/DonutChart/DonutChart.tsx +7 -3
- package/src/lib/Components/visualization/DonutChart/DonutRing.tsx +11 -1
- package/src/lib/Components/visualization/DonutChart/types.ts +1 -1
- package/src/lib/Components/visualization/Legend/Legend.test.tsx +9 -8
- package/src/lib/Components/visualization/Legend/Legend.tsx +1 -1
- package/src/lib/Components/visualization/Legend/types.ts +2 -2
- package/src/lib/Components/visualization/LineChart/LineChart.tsx +10 -2
- package/src/lib/Components/visualization/LineChart/types.ts +1 -1
- package/src/lib/Components/visualization/LineChart/utils.test.ts +4 -0
- package/src/lib/Components/visualization/LineChart/utils.ts +6 -2
- package/src/lib/Components/visualization/config.ts +0 -3
- package/src/translations/index.ts +2 -0
- package/src/{i18n → translations}/languages.ts +0 -6
- package/src/{i18n → translations}/locales/de.json +0 -3
- package/{dist/module/i18n → src/translations}/locales/en.json +9 -3
- package/{dist/module/i18n → src/translations}/locales/es.json +0 -3
- package/src/{i18n → translations}/locales/fr.json +0 -3
- package/{dist/module/i18n → src/translations}/locales/ja.json +0 -3
- package/src/{i18n → translations}/locales/ko.json +0 -3
- package/src/{i18n → translations}/locales/pt.json +0 -3
- package/src/{i18n → translations}/locales/ru.json +0 -3
- package/src/{i18n → translations}/locales/th.json +0 -3
- package/src/{i18n → translations}/locales/tr.json +0 -3
- package/{dist/module/i18n → src/translations}/locales/zh.json +0 -3
- package/src/translations/translations.test.ts +56 -0
- package/src/translations/translations.ts +21 -0
- package/dist/module/i18n/I18nProvider.js +0 -20
- package/dist/module/i18n/I18nProvider.js.map +0 -1
- package/dist/module/i18n/i18n.js +0 -82
- package/dist/module/i18n/i18n.js.map +0 -1
- package/dist/module/i18n/index.js +0 -6
- package/dist/module/i18n/index.js.map +0 -1
- package/dist/module/i18n/languages.js.map +0 -1
- package/dist/module/i18n/useCommonTranslation.js +0 -8
- package/dist/module/i18n/useCommonTranslation.js.map +0 -1
- package/dist/typescript/src/i18n/I18nProvider.d.ts +0 -8
- package/dist/typescript/src/i18n/I18nProvider.d.ts.map +0 -1
- package/dist/typescript/src/i18n/i18n.d.ts +0 -13
- package/dist/typescript/src/i18n/i18n.d.ts.map +0 -1
- package/dist/typescript/src/i18n/index.d.ts +0 -4
- package/dist/typescript/src/i18n/index.d.ts.map +0 -1
- package/dist/typescript/src/i18n/languages.d.ts.map +0 -1
- package/dist/typescript/src/i18n/useCommonTranslation.d.ts +0 -2
- package/dist/typescript/src/i18n/useCommonTranslation.d.ts.map +0 -1
- package/src/i18n/I18nProvider.tsx +0 -20
- package/src/i18n/i18n.ts +0 -107
- package/src/i18n/index.ts +0 -3
- package/src/i18n/useCommonTranslation.ts +0 -6
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';
|
|
4
|
+
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
5
|
+
import { toast, toastStore, EXIT_ANIMATION_MS } from '@ledgerhq/lumen-utils-shared';
|
|
6
|
+
import { act, fireEvent, render, screen } from '@testing-library/react-native';
|
|
7
|
+
import { useLayoutEffect } from 'react';
|
|
8
|
+
import { AccessibilityInfo, Platform } from 'react-native';
|
|
9
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
10
|
+
import { ThemeProvider } from "../ThemeProvider/ThemeProvider.js";
|
|
11
|
+
import { Toaster } from "./Toaster.js";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const initialMetrics = {
|
|
14
|
+
frame: {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
width: 320,
|
|
18
|
+
height: 640
|
|
19
|
+
},
|
|
20
|
+
insets: {
|
|
21
|
+
top: 0,
|
|
22
|
+
left: 0,
|
|
23
|
+
right: 0,
|
|
24
|
+
bottom: 0
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const TestProviders = ({
|
|
28
|
+
children
|
|
29
|
+
}) => /*#__PURE__*/_jsx(SafeAreaProvider, {
|
|
30
|
+
initialMetrics: initialMetrics,
|
|
31
|
+
children: /*#__PURE__*/_jsx(ThemeProvider, {
|
|
32
|
+
themes: ledgerLiveThemes,
|
|
33
|
+
colorScheme: "dark",
|
|
34
|
+
locale: "en",
|
|
35
|
+
children: children
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
const renderToaster = props => render(/*#__PURE__*/_jsx(TestProviders, {
|
|
39
|
+
children: /*#__PURE__*/_jsx(Toaster, {
|
|
40
|
+
...props
|
|
41
|
+
})
|
|
42
|
+
}));
|
|
43
|
+
const clearToastItems = () => {
|
|
44
|
+
for (const {
|
|
45
|
+
id
|
|
46
|
+
} of toastStore.getSnapshot()) {
|
|
47
|
+
toastStore.dismiss(id);
|
|
48
|
+
toastStore.dismiss(id);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const flushExit = () => {
|
|
52
|
+
act(() => {
|
|
53
|
+
jest.advanceTimersByTime(EXIT_ANIMATION_MS);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
describe('Toaster', () => {
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
clearToastItems();
|
|
59
|
+
});
|
|
60
|
+
describe('Timing', () => {
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
jest.useFakeTimers();
|
|
63
|
+
});
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
act(() => {
|
|
66
|
+
jest.runOnlyPendingTimers();
|
|
67
|
+
});
|
|
68
|
+
jest.useRealTimers();
|
|
69
|
+
});
|
|
70
|
+
it('should render a toast on notify', () => {
|
|
71
|
+
renderToaster();
|
|
72
|
+
act(() => {
|
|
73
|
+
toast.info({
|
|
74
|
+
title: 'Hello'
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
screen.getByText('Hello');
|
|
78
|
+
});
|
|
79
|
+
it('should show a toast that was notified before the toaster mounted', () => {
|
|
80
|
+
act(() => {
|
|
81
|
+
toast.info({
|
|
82
|
+
title: 'Queued early'
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
renderToaster();
|
|
86
|
+
screen.getByText('Queued early');
|
|
87
|
+
});
|
|
88
|
+
it('should apply Toaster props to toasts fired before its effects run', () => {
|
|
89
|
+
const EarlyNotifier = () => {
|
|
90
|
+
useLayoutEffect(() => {
|
|
91
|
+
toast.info({
|
|
92
|
+
title: 'First'
|
|
93
|
+
});
|
|
94
|
+
toast.info({
|
|
95
|
+
title: 'Second'
|
|
96
|
+
});
|
|
97
|
+
}, []);
|
|
98
|
+
return null;
|
|
99
|
+
};
|
|
100
|
+
render(/*#__PURE__*/_jsxs(TestProviders, {
|
|
101
|
+
children: [/*#__PURE__*/_jsx(EarlyNotifier, {}), /*#__PURE__*/_jsx(Toaster, {
|
|
102
|
+
maxItems: 1,
|
|
103
|
+
durations: {
|
|
104
|
+
info: 1000
|
|
105
|
+
}
|
|
106
|
+
})]
|
|
107
|
+
}));
|
|
108
|
+
expect(screen.queryByText('Second')).toBeNull();
|
|
109
|
+
act(() => {
|
|
110
|
+
jest.advanceTimersByTime(1000);
|
|
111
|
+
});
|
|
112
|
+
flushExit();
|
|
113
|
+
expect(screen.queryByText('First')).toBeNull();
|
|
114
|
+
screen.getByText('Second');
|
|
115
|
+
});
|
|
116
|
+
it('should auto-dismiss info after the default 5s', () => {
|
|
117
|
+
renderToaster();
|
|
118
|
+
act(() => {
|
|
119
|
+
toast.info({
|
|
120
|
+
title: 'Hello'
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
act(() => {
|
|
124
|
+
jest.advanceTimersByTime(4999);
|
|
125
|
+
});
|
|
126
|
+
screen.getByText('Hello');
|
|
127
|
+
act(() => {
|
|
128
|
+
jest.advanceTimersByTime(1);
|
|
129
|
+
});
|
|
130
|
+
flushExit();
|
|
131
|
+
expect(screen.queryByText('Hello')).toBeNull();
|
|
132
|
+
});
|
|
133
|
+
it('should keep warning toasts until dismissed', () => {
|
|
134
|
+
renderToaster();
|
|
135
|
+
act(() => {
|
|
136
|
+
toast.warning({
|
|
137
|
+
title: 'Careful'
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
act(() => {
|
|
141
|
+
jest.advanceTimersByTime(60000);
|
|
142
|
+
});
|
|
143
|
+
screen.getByText('Careful');
|
|
144
|
+
});
|
|
145
|
+
it('should queue items past maxItems and promote them as slots free', () => {
|
|
146
|
+
renderToaster({
|
|
147
|
+
maxItems: 1
|
|
148
|
+
});
|
|
149
|
+
act(() => {
|
|
150
|
+
toast.info({
|
|
151
|
+
title: 'First'
|
|
152
|
+
});
|
|
153
|
+
toast.info({
|
|
154
|
+
title: 'Second'
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
screen.getByText('First');
|
|
158
|
+
expect(screen.queryByText('Second')).toBeNull();
|
|
159
|
+
act(() => {
|
|
160
|
+
jest.advanceTimersByTime(5000);
|
|
161
|
+
});
|
|
162
|
+
flushExit();
|
|
163
|
+
expect(screen.queryByText('First')).toBeNull();
|
|
164
|
+
screen.getByText('Second');
|
|
165
|
+
});
|
|
166
|
+
it('should not keep a per-item duration across an update that omits it', () => {
|
|
167
|
+
renderToaster();
|
|
168
|
+
let id = '';
|
|
169
|
+
act(() => {
|
|
170
|
+
id = toast.loading({
|
|
171
|
+
title: 'Loading',
|
|
172
|
+
duration: 10000
|
|
173
|
+
}).id;
|
|
174
|
+
});
|
|
175
|
+
act(() => {
|
|
176
|
+
toast.update(id, {
|
|
177
|
+
appearance: 'success',
|
|
178
|
+
loading: false,
|
|
179
|
+
title: 'Done'
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
act(() => {
|
|
183
|
+
jest.advanceTimersByTime(5000);
|
|
184
|
+
});
|
|
185
|
+
flushExit();
|
|
186
|
+
expect(screen.queryByText('Done')).toBeNull();
|
|
187
|
+
});
|
|
188
|
+
it('should pause the timer while held and resume remaining time on release', () => {
|
|
189
|
+
const {
|
|
190
|
+
getByTestId
|
|
191
|
+
} = renderToaster();
|
|
192
|
+
act(() => {
|
|
193
|
+
toast.info({
|
|
194
|
+
title: 'Hold me'
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
act(() => {
|
|
198
|
+
jest.advanceTimersByTime(2000);
|
|
199
|
+
});
|
|
200
|
+
const entry = getByTestId('toast-entry');
|
|
201
|
+
act(() => {
|
|
202
|
+
entry.props.onTouchesDown();
|
|
203
|
+
});
|
|
204
|
+
act(() => {
|
|
205
|
+
jest.advanceTimersByTime(60000);
|
|
206
|
+
});
|
|
207
|
+
screen.getByText('Hold me');
|
|
208
|
+
act(() => {
|
|
209
|
+
entry.props.onTouchesUp({
|
|
210
|
+
numberOfTouches: 0
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
act(() => {
|
|
214
|
+
jest.advanceTimersByTime(2999);
|
|
215
|
+
});
|
|
216
|
+
screen.getByText('Hold me');
|
|
217
|
+
act(() => {
|
|
218
|
+
jest.advanceTimersByTime(1);
|
|
219
|
+
});
|
|
220
|
+
flushExit();
|
|
221
|
+
expect(screen.queryByText('Hold me')).toBeNull();
|
|
222
|
+
});
|
|
223
|
+
it('should stay paused while swiping and resume once the toast springs back', () => {
|
|
224
|
+
const {
|
|
225
|
+
getByTestId
|
|
226
|
+
} = renderToaster();
|
|
227
|
+
act(() => {
|
|
228
|
+
toast.info({
|
|
229
|
+
title: 'Swipe me'
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
act(() => {
|
|
233
|
+
jest.advanceTimersByTime(2000);
|
|
234
|
+
});
|
|
235
|
+
const entry = getByTestId('toast-entry');
|
|
236
|
+
act(() => {
|
|
237
|
+
entry.props.onTouchesDown();
|
|
238
|
+
entry.props.onUpdate({
|
|
239
|
+
translationX: 40
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
act(() => {
|
|
243
|
+
jest.advanceTimersByTime(60000);
|
|
244
|
+
});
|
|
245
|
+
screen.getByText('Swipe me');
|
|
246
|
+
act(() => {
|
|
247
|
+
entry.props.onEnd({
|
|
248
|
+
translationX: 20
|
|
249
|
+
});
|
|
250
|
+
entry.props.onFinalize();
|
|
251
|
+
});
|
|
252
|
+
act(() => {
|
|
253
|
+
jest.advanceTimersByTime(2999);
|
|
254
|
+
});
|
|
255
|
+
screen.getByText('Swipe me');
|
|
256
|
+
act(() => {
|
|
257
|
+
jest.advanceTimersByTime(1);
|
|
258
|
+
});
|
|
259
|
+
flushExit();
|
|
260
|
+
expect(screen.queryByText('Swipe me')).toBeNull();
|
|
261
|
+
});
|
|
262
|
+
it('should restart the timer when a loading toast becomes a success', () => {
|
|
263
|
+
renderToaster();
|
|
264
|
+
let id = '';
|
|
265
|
+
act(() => {
|
|
266
|
+
id = toast.loading({
|
|
267
|
+
title: 'Loading'
|
|
268
|
+
}).id;
|
|
269
|
+
});
|
|
270
|
+
act(() => {
|
|
271
|
+
jest.advanceTimersByTime(60000);
|
|
272
|
+
});
|
|
273
|
+
screen.getByText('Loading');
|
|
274
|
+
act(() => {
|
|
275
|
+
toast.update(id, {
|
|
276
|
+
appearance: 'success',
|
|
277
|
+
loading: false,
|
|
278
|
+
title: 'Done'
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
screen.getByText('Done');
|
|
282
|
+
act(() => {
|
|
283
|
+
jest.advanceTimersByTime(5000);
|
|
284
|
+
});
|
|
285
|
+
flushExit();
|
|
286
|
+
expect(screen.queryByText('Done')).toBeNull();
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
describe('Defaults', () => {
|
|
290
|
+
it('should default maxItems to 1', () => {
|
|
291
|
+
renderToaster();
|
|
292
|
+
act(() => {
|
|
293
|
+
toast.info({
|
|
294
|
+
title: 'First'
|
|
295
|
+
});
|
|
296
|
+
toast.info({
|
|
297
|
+
title: 'Second'
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
screen.getByText('First');
|
|
301
|
+
expect(screen.queryByText('Second')).toBeNull();
|
|
302
|
+
});
|
|
303
|
+
it('should default position to bottom', () => {
|
|
304
|
+
const {
|
|
305
|
+
getByTestId
|
|
306
|
+
} = renderToaster();
|
|
307
|
+
const viewport = getByTestId('toast-viewport');
|
|
308
|
+
expect(viewport.props.style.bottom).toBeDefined();
|
|
309
|
+
expect(viewport.props.style.top).toBeUndefined();
|
|
310
|
+
});
|
|
311
|
+
it('should anchor the viewport to the top when position is top', () => {
|
|
312
|
+
const {
|
|
313
|
+
getByTestId
|
|
314
|
+
} = renderToaster({
|
|
315
|
+
position: 'top'
|
|
316
|
+
});
|
|
317
|
+
const viewport = getByTestId('toast-viewport');
|
|
318
|
+
expect(viewport.props.style.top).toBeDefined();
|
|
319
|
+
expect(viewport.props.style.bottom).toBeUndefined();
|
|
320
|
+
});
|
|
321
|
+
it('should default insets to 0 and still apply the breathing-room gap', () => {
|
|
322
|
+
const {
|
|
323
|
+
getByTestId
|
|
324
|
+
} = renderToaster();
|
|
325
|
+
expect(getByTestId('toast-viewport').props.style.bottom).toBe(24);
|
|
326
|
+
});
|
|
327
|
+
it('adds a custom bottom inset to the gap instead of replacing it', () => {
|
|
328
|
+
const {
|
|
329
|
+
getByTestId
|
|
330
|
+
} = renderToaster({
|
|
331
|
+
insets: {
|
|
332
|
+
bottom: 80
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
expect(getByTestId('toast-viewport').props.style.bottom).toBe(104);
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
describe('Dismissal', () => {
|
|
339
|
+
beforeEach(() => {
|
|
340
|
+
jest.useFakeTimers();
|
|
341
|
+
});
|
|
342
|
+
afterEach(() => {
|
|
343
|
+
act(() => {
|
|
344
|
+
jest.runOnlyPendingTimers();
|
|
345
|
+
});
|
|
346
|
+
jest.useRealTimers();
|
|
347
|
+
});
|
|
348
|
+
it('should collapse the stack slot while exiting', () => {
|
|
349
|
+
renderToaster();
|
|
350
|
+
let id = '';
|
|
351
|
+
act(() => {
|
|
352
|
+
id = toast.warning({
|
|
353
|
+
title: 'Careful'
|
|
354
|
+
}).id;
|
|
355
|
+
});
|
|
356
|
+
act(() => {
|
|
357
|
+
toast.dismiss(id);
|
|
358
|
+
});
|
|
359
|
+
expect(screen.getByTestId('toast-collapse')).toHaveStyle({
|
|
360
|
+
height: 0
|
|
361
|
+
});
|
|
362
|
+
flushExit();
|
|
363
|
+
expect(screen.queryByText('Careful')).toBeNull();
|
|
364
|
+
});
|
|
365
|
+
it('should dismiss a single item by id and dismiss all', () => {
|
|
366
|
+
renderToaster({
|
|
367
|
+
maxItems: 2
|
|
368
|
+
});
|
|
369
|
+
let first = '';
|
|
370
|
+
act(() => {
|
|
371
|
+
first = toast.warning({
|
|
372
|
+
title: 'A'
|
|
373
|
+
}).id;
|
|
374
|
+
toast.warning({
|
|
375
|
+
title: 'B'
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
act(() => {
|
|
379
|
+
toast.dismiss(first);
|
|
380
|
+
});
|
|
381
|
+
screen.getByText('A');
|
|
382
|
+
flushExit();
|
|
383
|
+
expect(screen.queryByText('A')).toBeNull();
|
|
384
|
+
screen.getByText('B');
|
|
385
|
+
act(() => {
|
|
386
|
+
toast.dismissAll();
|
|
387
|
+
});
|
|
388
|
+
flushExit();
|
|
389
|
+
expect(screen.queryByText('B')).toBeNull();
|
|
390
|
+
});
|
|
391
|
+
it('should dismiss on a swipe past the threshold', () => {
|
|
392
|
+
const {
|
|
393
|
+
getByTestId
|
|
394
|
+
} = renderToaster();
|
|
395
|
+
act(() => {
|
|
396
|
+
toast.warning({
|
|
397
|
+
title: 'Swipe me'
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
const entry = getByTestId('toast-entry');
|
|
401
|
+
act(() => {
|
|
402
|
+
entry.props.onEnd({
|
|
403
|
+
translationX: 150
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
flushExit();
|
|
407
|
+
expect(screen.queryByText('Swipe me')).toBeNull();
|
|
408
|
+
});
|
|
409
|
+
it('should spring back and stay visible on a swipe under the threshold', () => {
|
|
410
|
+
const {
|
|
411
|
+
getByTestId
|
|
412
|
+
} = renderToaster();
|
|
413
|
+
act(() => {
|
|
414
|
+
toast.warning({
|
|
415
|
+
title: 'Stays put'
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
const entry = getByTestId('toast-entry');
|
|
419
|
+
act(() => {
|
|
420
|
+
entry.props.onEnd({
|
|
421
|
+
translationX: 20
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
screen.getByText('Stays put');
|
|
425
|
+
});
|
|
426
|
+
it('should stay visible when swiped past the threshold if not dismissible', () => {
|
|
427
|
+
const {
|
|
428
|
+
getByTestId
|
|
429
|
+
} = renderToaster();
|
|
430
|
+
act(() => {
|
|
431
|
+
toast.warning({
|
|
432
|
+
title: 'Locked',
|
|
433
|
+
dismissible: false
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
const entry = getByTestId('toast-entry');
|
|
437
|
+
act(() => {
|
|
438
|
+
entry.props.onEnd({
|
|
439
|
+
translationX: 150
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
flushExit();
|
|
443
|
+
screen.getByText('Locked');
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
describe('Accessibility', () => {
|
|
447
|
+
beforeEach(() => {
|
|
448
|
+
jest.useFakeTimers();
|
|
449
|
+
});
|
|
450
|
+
afterEach(() => {
|
|
451
|
+
act(() => {
|
|
452
|
+
jest.runOnlyPendingTimers();
|
|
453
|
+
});
|
|
454
|
+
jest.useRealTimers();
|
|
455
|
+
});
|
|
456
|
+
it('should expose the toast as one element labelled by its title', () => {
|
|
457
|
+
renderToaster();
|
|
458
|
+
act(() => {
|
|
459
|
+
toast.info({
|
|
460
|
+
title: 'Saved'
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
const entry = screen.getByTestId('toast-entry');
|
|
464
|
+
expect(entry.props.accessible).toBe(true);
|
|
465
|
+
expect(entry.props.accessibilityLabel).toBe('Saved');
|
|
466
|
+
});
|
|
467
|
+
it('should dismiss through the dismiss accessibility action', () => {
|
|
468
|
+
renderToaster();
|
|
469
|
+
act(() => {
|
|
470
|
+
toast.warning({
|
|
471
|
+
title: 'Dismiss me'
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
expect(screen.getByTestId('toast-entry').props.accessibilityActions).toContainEqual({
|
|
475
|
+
name: 'dismiss',
|
|
476
|
+
label: 'Close'
|
|
477
|
+
});
|
|
478
|
+
fireEvent(screen.getByTestId('toast-entry'), 'accessibilityAction', {
|
|
479
|
+
nativeEvent: {
|
|
480
|
+
actionName: 'dismiss'
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
flushExit();
|
|
484
|
+
expect(screen.queryByText('Dismiss me')).toBeNull();
|
|
485
|
+
});
|
|
486
|
+
it('should dismiss on the iOS escape gesture', () => {
|
|
487
|
+
renderToaster();
|
|
488
|
+
act(() => {
|
|
489
|
+
toast.warning({
|
|
490
|
+
title: 'Escape me'
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
fireEvent(screen.getByTestId('toast-entry'), 'accessibilityEscape');
|
|
494
|
+
flushExit();
|
|
495
|
+
expect(screen.queryByText('Escape me')).toBeNull();
|
|
496
|
+
});
|
|
497
|
+
it('should expose the inline action as an accessibility action', () => {
|
|
498
|
+
const onAction = jest.fn();
|
|
499
|
+
renderToaster();
|
|
500
|
+
act(() => {
|
|
501
|
+
toast.warning({
|
|
502
|
+
title: 'Deleted',
|
|
503
|
+
action: {
|
|
504
|
+
label: 'Undo',
|
|
505
|
+
onAction
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
const entry = screen.getByTestId('toast-entry');
|
|
510
|
+
expect(entry.props.accessibilityActions).toContainEqual({
|
|
511
|
+
name: 'toastAction',
|
|
512
|
+
label: 'Undo'
|
|
513
|
+
});
|
|
514
|
+
fireEvent(entry, 'accessibilityAction', {
|
|
515
|
+
nativeEvent: {
|
|
516
|
+
actionName: 'toastAction'
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
expect(onAction).toHaveBeenCalledTimes(1);
|
|
520
|
+
screen.getByText('Deleted');
|
|
521
|
+
});
|
|
522
|
+
it('should not offer dismissal for a non-dismissible toast', () => {
|
|
523
|
+
renderToaster();
|
|
524
|
+
act(() => {
|
|
525
|
+
toast.info({
|
|
526
|
+
title: 'Locked',
|
|
527
|
+
dismissible: false
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
const entry = screen.getByTestId('toast-entry');
|
|
531
|
+
expect(entry.props.accessibilityActions).toEqual([]);
|
|
532
|
+
expect(entry.props.onAccessibilityEscape).toBeUndefined();
|
|
533
|
+
});
|
|
534
|
+
describe('on iOS', () => {
|
|
535
|
+
const originalOS = Platform.OS;
|
|
536
|
+
beforeEach(() => {
|
|
537
|
+
Platform.OS = 'ios';
|
|
538
|
+
});
|
|
539
|
+
afterEach(() => {
|
|
540
|
+
Platform.OS = originalOS;
|
|
541
|
+
});
|
|
542
|
+
it('should announce the title, interrupting only for warning and error', () => {
|
|
543
|
+
const announce = jest.spyOn(AccessibilityInfo, 'announceForAccessibilityWithOptions').mockImplementation(() => undefined);
|
|
544
|
+
renderToaster({
|
|
545
|
+
maxItems: 2
|
|
546
|
+
});
|
|
547
|
+
act(() => {
|
|
548
|
+
toast.info({
|
|
549
|
+
title: 'Heads up'
|
|
550
|
+
});
|
|
551
|
+
toast.error({
|
|
552
|
+
title: 'Failed'
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
expect(announce).toHaveBeenCalledWith('Heads up', {
|
|
556
|
+
queue: true
|
|
557
|
+
});
|
|
558
|
+
expect(announce).toHaveBeenCalledWith('Failed', {
|
|
559
|
+
queue: false
|
|
560
|
+
});
|
|
561
|
+
announce.mockRestore();
|
|
562
|
+
});
|
|
563
|
+
it('should announce again when the title changes', () => {
|
|
564
|
+
const announce = jest.spyOn(AccessibilityInfo, 'announceForAccessibilityWithOptions').mockImplementation(() => undefined);
|
|
565
|
+
renderToaster();
|
|
566
|
+
let id = '';
|
|
567
|
+
act(() => {
|
|
568
|
+
id = toast.info({
|
|
569
|
+
title: 'Uploading',
|
|
570
|
+
loading: true
|
|
571
|
+
}).id;
|
|
572
|
+
});
|
|
573
|
+
act(() => {
|
|
574
|
+
toast.update(id, {
|
|
575
|
+
title: 'Uploaded',
|
|
576
|
+
appearance: 'success'
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
expect(announce).toHaveBeenLastCalledWith('Uploaded', {
|
|
580
|
+
queue: true
|
|
581
|
+
});
|
|
582
|
+
announce.mockRestore();
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
describe('promise', () => {
|
|
587
|
+
it('should move the toast from loading to success', async () => {
|
|
588
|
+
renderToaster();
|
|
589
|
+
let resolveFn = () => {};
|
|
590
|
+
const promise = new Promise(resolve => {
|
|
591
|
+
resolveFn = resolve;
|
|
592
|
+
});
|
|
593
|
+
act(() => {
|
|
594
|
+
toast.promise(promise, {
|
|
595
|
+
loading: {
|
|
596
|
+
title: 'Saving'
|
|
597
|
+
},
|
|
598
|
+
success: {
|
|
599
|
+
title: 'Saved'
|
|
600
|
+
},
|
|
601
|
+
error: {
|
|
602
|
+
title: 'Failed'
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
screen.getByText('Saving');
|
|
607
|
+
resolveFn('ok');
|
|
608
|
+
expect(await screen.findByText('Saved')).toBeTruthy();
|
|
609
|
+
});
|
|
610
|
+
it('should drop the loading action when success omits it', async () => {
|
|
611
|
+
renderToaster();
|
|
612
|
+
let resolveFn = () => {};
|
|
613
|
+
const promise = new Promise(resolve => {
|
|
614
|
+
resolveFn = resolve;
|
|
615
|
+
});
|
|
616
|
+
act(() => {
|
|
617
|
+
toast.promise(promise, {
|
|
618
|
+
loading: {
|
|
619
|
+
title: 'Saving',
|
|
620
|
+
action: {
|
|
621
|
+
label: 'Cancel',
|
|
622
|
+
onAction: () => {}
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
success: {
|
|
626
|
+
title: 'Saved'
|
|
627
|
+
},
|
|
628
|
+
error: {
|
|
629
|
+
title: 'Failed'
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
screen.getByText('Cancel');
|
|
634
|
+
resolveFn('ok');
|
|
635
|
+
expect(await screen.findByText('Saved')).toBeTruthy();
|
|
636
|
+
expect(screen.queryByText('Cancel')).toBeNull();
|
|
637
|
+
});
|
|
638
|
+
it('should drop the loading action when error omits it', async () => {
|
|
639
|
+
renderToaster();
|
|
640
|
+
let rejectFn = () => {};
|
|
641
|
+
const promise = new Promise((_resolve, reject) => {
|
|
642
|
+
rejectFn = reject;
|
|
643
|
+
});
|
|
644
|
+
act(() => {
|
|
645
|
+
toast.promise(promise, {
|
|
646
|
+
loading: {
|
|
647
|
+
title: 'Saving',
|
|
648
|
+
action: {
|
|
649
|
+
label: 'Cancel',
|
|
650
|
+
onAction: () => {}
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
success: {
|
|
654
|
+
title: 'Saved'
|
|
655
|
+
},
|
|
656
|
+
error: {
|
|
657
|
+
title: 'Failed'
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
screen.getByText('Cancel');
|
|
662
|
+
rejectFn(new Error('nope'));
|
|
663
|
+
expect(await screen.findByText('Failed')).toBeTruthy();
|
|
664
|
+
expect(screen.queryByText('Cancel')).toBeNull();
|
|
665
|
+
});
|
|
666
|
+
it('should restore dismissal when error omits dismissible', async () => {
|
|
667
|
+
renderToaster();
|
|
668
|
+
let rejectFn = () => {};
|
|
669
|
+
const promise = new Promise((_resolve, reject) => {
|
|
670
|
+
rejectFn = reject;
|
|
671
|
+
});
|
|
672
|
+
act(() => {
|
|
673
|
+
toast.promise(promise, {
|
|
674
|
+
loading: {
|
|
675
|
+
title: 'Saving',
|
|
676
|
+
dismissible: false
|
|
677
|
+
},
|
|
678
|
+
success: {
|
|
679
|
+
title: 'Saved'
|
|
680
|
+
},
|
|
681
|
+
error: {
|
|
682
|
+
title: 'Failed'
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
expect(screen.getByTestId('toast-entry').props.onAccessibilityEscape).toBeUndefined();
|
|
687
|
+
rejectFn(new Error('nope'));
|
|
688
|
+
expect(await screen.findByText('Failed')).toBeTruthy();
|
|
689
|
+
expect(screen.getByTestId('toast-entry').props.accessibilityActions).toContainEqual(expect.objectContaining({
|
|
690
|
+
name: 'dismiss'
|
|
691
|
+
}));
|
|
692
|
+
});
|
|
693
|
+
it('should move the toast from loading to error on rejection', async () => {
|
|
694
|
+
renderToaster();
|
|
695
|
+
let rejectFn = () => {};
|
|
696
|
+
const promise = new Promise((_resolve, reject) => {
|
|
697
|
+
rejectFn = reject;
|
|
698
|
+
});
|
|
699
|
+
act(() => {
|
|
700
|
+
toast.promise(promise, {
|
|
701
|
+
loading: {
|
|
702
|
+
title: 'Saving'
|
|
703
|
+
},
|
|
704
|
+
success: {
|
|
705
|
+
title: 'Saved'
|
|
706
|
+
},
|
|
707
|
+
error: {
|
|
708
|
+
title: 'Failed'
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
screen.getByText('Saving');
|
|
713
|
+
rejectFn(new Error('nope'));
|
|
714
|
+
expect(await screen.findByText('Failed')).toBeTruthy();
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
describe('Multiple instances', () => {
|
|
718
|
+
it('warns when a second Toaster mounts while one is already mounted', () => {
|
|
719
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {
|
|
720
|
+
return;
|
|
721
|
+
});
|
|
722
|
+
const first = renderToaster();
|
|
723
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
724
|
+
const second = renderToaster();
|
|
725
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
726
|
+
first.unmount();
|
|
727
|
+
second.unmount();
|
|
728
|
+
warnSpy.mockRestore();
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
//# sourceMappingURL=Toaster.test.js.map
|