ignite-parse-auth-kit 1.0.0
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/CONTRIBUTING.md +0 -0
- package/LICENSE +21 -0
- package/README.md +492 -0
- package/app/app.tsx +116 -0
- package/app/components/AlertTongle.tsx +105 -0
- package/app/components/AutoImage.tsx +89 -0
- package/app/components/Button.tsx +248 -0
- package/app/components/Card.tsx +314 -0
- package/app/components/EmptyState.tsx +248 -0
- package/app/components/Header.tsx +332 -0
- package/app/components/Icon.tsx +140 -0
- package/app/components/ListItem.tsx +243 -0
- package/app/components/ListView.tsx +42 -0
- package/app/components/Screen.tsx +305 -0
- package/app/components/Text.test.tsx +23 -0
- package/app/components/Text.tsx +116 -0
- package/app/components/TextField.tsx +292 -0
- package/app/components/Toggle/Checkbox.tsx +123 -0
- package/app/components/Toggle/Radio.tsx +106 -0
- package/app/components/Toggle/Switch.tsx +264 -0
- package/app/components/Toggle/Toggle.tsx +285 -0
- package/app/components/index copy.ts +15 -0
- package/app/components/index.ts +18 -0
- package/app/config/config.base.ts +26 -0
- package/app/config/config.dev.ts +10 -0
- package/app/config/config.prod.ts +10 -0
- package/app/config/index.ts +28 -0
- package/app/context/AuthContext.tsx +14 -0
- package/app/context/EpisodeContext.tsx +136 -0
- package/app/context/auth/AuthProvider.tsx +340 -0
- package/app/context/auth/hooks.ts +29 -0
- package/app/context/auth/index.ts +38 -0
- package/app/context/auth/reducer.ts +68 -0
- package/app/context/auth/services.ts +394 -0
- package/app/context/auth/types.ts +99 -0
- package/app/context/auth/validation.ts +45 -0
- package/app/devtools/ReactotronClient.ts +9 -0
- package/app/devtools/ReactotronClient.web.ts +12 -0
- package/app/devtools/ReactotronConfig.ts +139 -0
- package/app/i18n/ar.ts +126 -0
- package/app/i18n/demo-ar.ts +464 -0
- package/app/i18n/demo-en.ts +462 -0
- package/app/i18n/demo-es.ts +469 -0
- package/app/i18n/demo-fr.ts +471 -0
- package/app/i18n/demo-hi.ts +468 -0
- package/app/i18n/demo-ja.ts +464 -0
- package/app/i18n/demo-ko.ts +457 -0
- package/app/i18n/en.ts +146 -0
- package/app/i18n/es.ts +132 -0
- package/app/i18n/fr.ts +132 -0
- package/app/i18n/hi.ts +131 -0
- package/app/i18n/index.ts +86 -0
- package/app/i18n/ja.ts +130 -0
- package/app/i18n/ko.ts +129 -0
- package/app/i18n/translate.ts +33 -0
- package/app/lib/Parse/index.ts +2 -0
- package/app/lib/Parse/parse.ts +62 -0
- package/app/navigators/AppNavigator.tsx +145 -0
- package/app/navigators/DemoNavigator.tsx +137 -0
- package/app/navigators/navigationUtilities.ts +208 -0
- package/app/screens/ChooseAuthScreen.tsx +224 -0
- package/app/screens/DemoCommunityScreen.tsx +141 -0
- package/app/screens/DemoDebugScreen.tsx +192 -0
- package/app/screens/DemoPodcastListScreen.tsx +387 -0
- package/app/screens/DemoShowroomScreen/DemoDivider.tsx +66 -0
- package/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx +313 -0
- package/app/screens/DemoShowroomScreen/DemoUseCase.tsx +52 -0
- package/app/screens/DemoShowroomScreen/DrawerIconButton.tsx +120 -0
- package/app/screens/DemoShowroomScreen/SectionListWithKeyboardAwareScrollView.tsx +59 -0
- package/app/screens/DemoShowroomScreen/demos/DemoAutoImage.tsx +230 -0
- package/app/screens/DemoShowroomScreen/demos/DemoButton.tsx +234 -0
- package/app/screens/DemoShowroomScreen/demos/DemoCard.tsx +181 -0
- package/app/screens/DemoShowroomScreen/demos/DemoEmptyState.tsx +78 -0
- package/app/screens/DemoShowroomScreen/demos/DemoHeader.tsx +151 -0
- package/app/screens/DemoShowroomScreen/demos/DemoIcon.tsx +115 -0
- package/app/screens/DemoShowroomScreen/demos/DemoListItem.tsx +218 -0
- package/app/screens/DemoShowroomScreen/demos/DemoText.tsx +144 -0
- package/app/screens/DemoShowroomScreen/demos/DemoTextField.tsx +233 -0
- package/app/screens/DemoShowroomScreen/demos/DemoToggle.tsx +354 -0
- package/app/screens/DemoShowroomScreen/demos/index.ts +12 -0
- package/app/screens/ErrorScreen/ErrorBoundary.tsx +76 -0
- package/app/screens/ErrorScreen/ErrorDetails.tsx +98 -0
- package/app/screens/ForgetPasswordScreen.tsx +180 -0
- package/app/screens/LoginScreen.tsx +260 -0
- package/app/screens/RegisterScreen.tsx +395 -0
- package/app/screens/WelcomeScreen.tsx +114 -0
- package/app/services/api/apiProblem.test.ts +73 -0
- package/app/services/api/apiProblem.ts +74 -0
- package/app/services/api/index.ts +91 -0
- package/app/services/api/types.ts +50 -0
- package/app/theme/colors.ts +85 -0
- package/app/theme/colorsDark.ts +50 -0
- package/app/theme/context.tsx +145 -0
- package/app/theme/context.utils.ts +25 -0
- package/app/theme/spacing.ts +14 -0
- package/app/theme/spacingDark.ts +14 -0
- package/app/theme/styles.ts +24 -0
- package/app/theme/theme.ts +23 -0
- package/app/theme/timing.ts +6 -0
- package/app/theme/types.ts +64 -0
- package/app/theme/typography.ts +71 -0
- package/app/utils/crashReporting.ts +62 -0
- package/app/utils/delay.ts +6 -0
- package/app/utils/formatDate.ts +49 -0
- package/app/utils/gestureHandler.native.ts +3 -0
- package/app/utils/gestureHandler.ts +6 -0
- package/app/utils/hasValidStringProp.ts +11 -0
- package/app/utils/openLinkInBrowser.ts +8 -0
- package/app/utils/storage/index.ts +82 -0
- package/app/utils/storage/storage.test.ts +61 -0
- package/app/utils/useHeader.tsx +37 -0
- package/app/utils/useIsMounted.ts +18 -0
- package/app/utils/useSafeAreaInsetsStyle.ts +46 -0
- package/app.config.ts +39 -0
- package/app.json +67 -0
- package/assets/icons/back.png +0 -0
- package/assets/icons/back@2x.png +0 -0
- package/assets/icons/back@3x.png +0 -0
- package/assets/icons/bell.png +0 -0
- package/assets/icons/bell@2x.png +0 -0
- package/assets/icons/bell@3x.png +0 -0
- package/assets/icons/caretLeft.png +0 -0
- package/assets/icons/caretLeft@2x.png +0 -0
- package/assets/icons/caretLeft@3x.png +0 -0
- package/assets/icons/caretRight.png +0 -0
- package/assets/icons/caretRight@2x.png +0 -0
- package/assets/icons/caretRight@3x.png +0 -0
- package/assets/icons/check.png +0 -0
- package/assets/icons/check@2x.png +0 -0
- package/assets/icons/check@3x.png +0 -0
- package/assets/icons/demo/clap.png +0 -0
- package/assets/icons/demo/clap@2x.png +0 -0
- package/assets/icons/demo/clap@3x.png +0 -0
- package/assets/icons/demo/community.png +0 -0
- package/assets/icons/demo/community@2x.png +0 -0
- package/assets/icons/demo/community@3x.png +0 -0
- package/assets/icons/demo/components.png +0 -0
- package/assets/icons/demo/components@2x.png +0 -0
- package/assets/icons/demo/components@3x.png +0 -0
- package/assets/icons/demo/debug.png +0 -0
- package/assets/icons/demo/debug@2x.png +0 -0
- package/assets/icons/demo/debug@3x.png +0 -0
- package/assets/icons/demo/github.png +0 -0
- package/assets/icons/demo/github@2x.png +0 -0
- package/assets/icons/demo/github@3x.png +0 -0
- package/assets/icons/demo/heart.png +0 -0
- package/assets/icons/demo/heart@2x.png +0 -0
- package/assets/icons/demo/heart@3x.png +0 -0
- package/assets/icons/demo/pin.png +0 -0
- package/assets/icons/demo/pin@2x.png +0 -0
- package/assets/icons/demo/pin@3x.png +0 -0
- package/assets/icons/demo/podcast.png +0 -0
- package/assets/icons/demo/podcast@2x.png +0 -0
- package/assets/icons/demo/podcast@3x.png +0 -0
- package/assets/icons/demo/slack.png +0 -0
- package/assets/icons/demo/slack@2x.png +0 -0
- package/assets/icons/demo/slack@3x.png +0 -0
- package/assets/icons/google.png +0 -0
- package/assets/icons/hidden.png +0 -0
- package/assets/icons/hidden@2x.png +0 -0
- package/assets/icons/hidden@3x.png +0 -0
- package/assets/icons/ladybug.png +0 -0
- package/assets/icons/ladybug@2x.png +0 -0
- package/assets/icons/ladybug@3x.png +0 -0
- package/assets/icons/lock.png +0 -0
- package/assets/icons/lock@2x.png +0 -0
- package/assets/icons/lock@3x.png +0 -0
- package/assets/icons/menu.png +0 -0
- package/assets/icons/menu@2x.png +0 -0
- package/assets/icons/menu@3x.png +0 -0
- package/assets/icons/more.png +0 -0
- package/assets/icons/more@2x.png +0 -0
- package/assets/icons/more@3x.png +0 -0
- package/assets/icons/settings.png +0 -0
- package/assets/icons/settings@2x.png +0 -0
- package/assets/icons/settings@3x.png +0 -0
- package/assets/icons/view.png +0 -0
- package/assets/icons/view@2x.png +0 -0
- package/assets/icons/view@3x.png +0 -0
- package/assets/icons/x.png +0 -0
- package/assets/icons/x@2x.png +0 -0
- package/assets/icons/x@3x.png +0 -0
- package/assets/images/app-icon-all.png +0 -0
- package/assets/images/app-icon-android-adaptive-background.png +0 -0
- package/assets/images/app-icon-android-adaptive-foreground.png +0 -0
- package/assets/images/app-icon-android-legacy.png +0 -0
- package/assets/images/app-icon-ios.png +0 -0
- package/assets/images/app-icon-web-favicon.png +0 -0
- package/assets/images/demo/cr-logo.png +0 -0
- package/assets/images/demo/cr-logo@2x.png +0 -0
- package/assets/images/demo/cr-logo@3x.png +0 -0
- package/assets/images/demo/rnl-logo.png +0 -0
- package/assets/images/demo/rnl-logo@2x.png +0 -0
- package/assets/images/demo/rnl-logo@3x.png +0 -0
- package/assets/images/demo/rnn-logo.png +0 -0
- package/assets/images/demo/rnn-logo@2x.png +0 -0
- package/assets/images/demo/rnn-logo@3x.png +0 -0
- package/assets/images/demo/rnr-image-1.png +0 -0
- package/assets/images/demo/rnr-image-1@2x.png +0 -0
- package/assets/images/demo/rnr-image-1@3x.png +0 -0
- package/assets/images/demo/rnr-image-2.png +0 -0
- package/assets/images/demo/rnr-image-2@2x.png +0 -0
- package/assets/images/demo/rnr-image-2@3x.png +0 -0
- package/assets/images/demo/rnr-image-3.png +0 -0
- package/assets/images/demo/rnr-image-3@2x.png +0 -0
- package/assets/images/demo/rnr-image-3@3x.png +0 -0
- package/assets/images/demo/rnr-logo.png +0 -0
- package/assets/images/demo/rnr-logo@2x.png +0 -0
- package/assets/images/demo/rnr-logo@3x.png +0 -0
- package/assets/images/logo.png +0 -0
- package/assets/images/logo@2x.png +0 -0
- package/assets/images/logo@3x.png +0 -0
- package/assets/images/sad-face.png +0 -0
- package/assets/images/sad-face@2x.png +0 -0
- package/assets/images/sad-face@3x.png +0 -0
- package/assets/images/welcome-face.png +0 -0
- package/assets/images/welcome-face@2x.png +0 -0
- package/assets/images/welcome-face@3x.png +0 -0
- package/babel.config.js +7 -0
- package/bin/cli.js +196 -0
- package/ignite/templates/app-icon/android-adaptive-background.png +0 -0
- package/ignite/templates/app-icon/android-adaptive-foreground.png +0 -0
- package/ignite/templates/app-icon/android-legacy.png +0 -0
- package/ignite/templates/app-icon/ios-universal.png +0 -0
- package/ignite/templates/component/NAME.tsx.ejs +39 -0
- package/ignite/templates/navigator/NAMENavigator.tsx.ejs +18 -0
- package/ignite/templates/screen/NAMEScreen.tsx.ejs +29 -0
- package/ignite/templates/splash-screen/logo.png +0 -0
- package/index.tsx +9 -0
- package/jest.config.js +5 -0
- package/metro.config.js +31 -0
- package/package.json +166 -0
- package/plugins/withSplashScreen.ts +69 -0
- package/src/app/_layout.tsx +58 -0
- package/src/app/index.tsx +5 -0
- package/test/i18n.test.ts +75 -0
- package/test/mockFile.ts +6 -0
- package/test/setup.ts +58 -0
- package/test/test-tsconfig.json +8 -0
- package/tsconfig.json +52 -0
- package/types/lib.es5.d.ts +25 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ConfigPlugin, withStringsXml, AndroidConfig, withAndroidStyles } from "expo/config-plugins"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Expo Config Plugin to help address the double splash screen issue with `expo-splash-screen`
|
|
6
|
+
* See more information about this issue here: https://github.com/expo/expo/issues/16084
|
|
7
|
+
*
|
|
8
|
+
* How it works:
|
|
9
|
+
* 1) Replace the default splash screen with a transparent screen
|
|
10
|
+
* 2) Set the splash screen status bar to translucent
|
|
11
|
+
*/
|
|
12
|
+
export const withSplashScreen: ConfigPlugin = (config) => {
|
|
13
|
+
config = withAndroidSplashScreen(config)
|
|
14
|
+
return config
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Android implementation of the config plugin - the only platform needed for this plugin.
|
|
19
|
+
* However, it is good practice to break up your config plugins from the exported
|
|
20
|
+
* function into parts by platform. For example, if it was needed, we would also
|
|
21
|
+
* add `withIosSplashScreen` for the iOS implementation.
|
|
22
|
+
*/
|
|
23
|
+
const withAndroidSplashScreen: ConfigPlugin = (config) => {
|
|
24
|
+
config = withCustomStylesXml(config)
|
|
25
|
+
config = withCustomStringsXml(config)
|
|
26
|
+
return config
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Modifies the `android/app/src/main/res/values/strings.xml` file to add the following string:
|
|
31
|
+
*
|
|
32
|
+
* <string name="expo_splash_screen_status_bar_translucent" translatable="false">true</string>
|
|
33
|
+
*/
|
|
34
|
+
const withCustomStringsXml: ConfigPlugin = (config) =>
|
|
35
|
+
withStringsXml(config, (modConfig) => {
|
|
36
|
+
modConfig.modResults = AndroidConfig.Strings.setStringItem(
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
_: "true",
|
|
40
|
+
$: {
|
|
41
|
+
name: "expo_splash_screen_status_bar_translucent",
|
|
42
|
+
translatable: "false",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
modConfig.modResults,
|
|
47
|
+
)
|
|
48
|
+
return modConfig
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Modifies the `android/app/src/main/res/values/styles.xml` file to append the
|
|
53
|
+
* the following to the Theme.App.SplashScreen style:
|
|
54
|
+
*
|
|
55
|
+
* <item name="android:windowIsTranslucent">true</item>
|
|
56
|
+
*/
|
|
57
|
+
const withCustomStylesXml: ConfigPlugin = (config) =>
|
|
58
|
+
withAndroidStyles(config, async (modConfig) => {
|
|
59
|
+
modConfig.modResults = AndroidConfig.Styles.assignStylesValue(modConfig.modResults, {
|
|
60
|
+
add: true,
|
|
61
|
+
name: "android:windowIsTranslucent",
|
|
62
|
+
value: "true",
|
|
63
|
+
parent: {
|
|
64
|
+
name: "Theme.App.SplashScreen",
|
|
65
|
+
parent: "AppTheme",
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
return modConfig
|
|
69
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useEffect, useState } from "react"
|
|
2
|
+
import { Slot, SplashScreen } from "expo-router"
|
|
3
|
+
import { useFonts } from "@expo-google-fonts/space-grotesk"
|
|
4
|
+
import { KeyboardProvider } from "react-native-keyboard-controller"
|
|
5
|
+
import { initialWindowMetrics, SafeAreaProvider } from "react-native-safe-area-context"
|
|
6
|
+
|
|
7
|
+
import { initI18n } from "@/i18n"
|
|
8
|
+
import { ThemeProvider } from "@/theme/context"
|
|
9
|
+
import { customFontsToLoad } from "@/theme/typography"
|
|
10
|
+
import { loadDateFnsLocale } from "@/utils/formatDate"
|
|
11
|
+
|
|
12
|
+
SplashScreen.preventAutoHideAsync()
|
|
13
|
+
|
|
14
|
+
if (__DEV__) {
|
|
15
|
+
// Load Reactotron configuration in development. We don't want to
|
|
16
|
+
// include this in our production bundle, so we are using `if (__DEV__)`
|
|
17
|
+
// to only execute this in development.
|
|
18
|
+
require("src/devtools/ReactotronConfig.ts")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { ErrorBoundary } from "@/components/ErrorBoundary/ErrorBoundary"
|
|
22
|
+
|
|
23
|
+
export default function Root() {
|
|
24
|
+
const [fontsLoaded, fontError] = useFonts(customFontsToLoad)
|
|
25
|
+
const [isI18nInitialized, setIsI18nInitialized] = useState(false)
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
initI18n()
|
|
29
|
+
.then(() => setIsI18nInitialized(true))
|
|
30
|
+
.then(() => loadDateFnsLocale())
|
|
31
|
+
}, [])
|
|
32
|
+
|
|
33
|
+
const loaded = fontsLoaded && isI18nInitialized
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (fontError) throw fontError
|
|
37
|
+
}, [fontError])
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (loaded) {
|
|
41
|
+
SplashScreen.hideAsync()
|
|
42
|
+
}
|
|
43
|
+
}, [loaded])
|
|
44
|
+
|
|
45
|
+
if (!loaded) {
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
|
|
51
|
+
<ThemeProvider>
|
|
52
|
+
<KeyboardProvider>
|
|
53
|
+
<Slot />
|
|
54
|
+
</KeyboardProvider>
|
|
55
|
+
</ThemeProvider>
|
|
56
|
+
</SafeAreaProvider>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { exec } from "child_process"
|
|
2
|
+
|
|
3
|
+
import en from "../app/i18n/en"
|
|
4
|
+
|
|
5
|
+
// Use this array for keys that for whatever reason aren't greppable so they
|
|
6
|
+
// don't hold your test suite hostage by always failing.
|
|
7
|
+
const EXCEPTIONS: string[] = [
|
|
8
|
+
// "welcomeScreen:readyForLaunch",
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This translation key actually shows up in a comment describing the usage of the translate
|
|
12
|
+
* function in the app/i18n/translate.ts file. Because the grep command in the i18n test below
|
|
13
|
+
* doesn't account for commented out code, we must manually exclude it so tests don't fail
|
|
14
|
+
* because of a comment.
|
|
15
|
+
*/
|
|
16
|
+
"hello",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
function iterate(obj, stack, array) {
|
|
20
|
+
for (const property in obj) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(obj, property)) {
|
|
22
|
+
if (typeof (obj as object)[property] === "object") {
|
|
23
|
+
iterate(obj[property], `${stack}.${property}`, array)
|
|
24
|
+
} else {
|
|
25
|
+
array.push(`${stack.slice(1)}.${property}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return array
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This tests your codebase for missing i18n strings so you can avoid error strings at render time
|
|
35
|
+
*
|
|
36
|
+
* It was taken from https://gist.github.com/Michaelvilleneuve/8808ba2775536665d95b7577c9d8d5a1
|
|
37
|
+
* and modified slightly to account for our Ignite higher order components,
|
|
38
|
+
* which take 'tx' and 'fooTx' props.
|
|
39
|
+
* The grep command is nasty looking, but it's essentially searching the codebase for a few different things:
|
|
40
|
+
*
|
|
41
|
+
* tx="*"
|
|
42
|
+
* Tx=""
|
|
43
|
+
* tx={""}
|
|
44
|
+
* Tx={""}
|
|
45
|
+
* translate(""
|
|
46
|
+
*
|
|
47
|
+
* and then grabs the i18n key between the double quotes
|
|
48
|
+
*
|
|
49
|
+
* This approach isn't 100% perfect. If you are storing your key string in a variable because you
|
|
50
|
+
* are setting it conditionally, then it won't be picked up.
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
describe("i18n", () => {
|
|
55
|
+
test("There are no missing keys", (done) => {
|
|
56
|
+
// Actual command output:
|
|
57
|
+
// grep "[T\|t]x=[{]\?\"\S*\"[}]\?\|translate(\"\S*\"" -ohr './app' | grep -o "\".*\""
|
|
58
|
+
const command = `grep "[T\\|t]x=[{]\\?\\"\\S*\\"[}]\\?\\|translate(\\"\\S*\\"" -ohr './app' | grep -o "\\".*\\""`
|
|
59
|
+
exec(command, (_, stdout) => {
|
|
60
|
+
const allTranslationsDefinedOld = iterate(en, "", [])
|
|
61
|
+
// Replace first instance of "." because of i18next namespace separator
|
|
62
|
+
const allTranslationsDefined = allTranslationsDefinedOld.map((key) => key.replace(".", ":"))
|
|
63
|
+
const allTranslationsUsed = stdout.replace(/"/g, "").split("\n")
|
|
64
|
+
allTranslationsUsed.splice(-1, 1)
|
|
65
|
+
|
|
66
|
+
for (let i = 0; i < allTranslationsUsed.length; i += 1) {
|
|
67
|
+
if (!EXCEPTIONS.includes(allTranslationsUsed[i])) {
|
|
68
|
+
// You can add keys to EXCEPTIONS (above) if you don't want them included in the test
|
|
69
|
+
expect(allTranslationsDefined).toContainEqual(allTranslationsUsed[i])
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
done()
|
|
73
|
+
})
|
|
74
|
+
}, 240000)
|
|
75
|
+
})
|
package/test/mockFile.ts
ADDED
package/test/setup.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// we always make sure 'react-native' gets included first
|
|
2
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
|
+
import * as ReactNative from "react-native"
|
|
4
|
+
|
|
5
|
+
import mockFile from "./mockFile"
|
|
6
|
+
|
|
7
|
+
// libraries to mock
|
|
8
|
+
jest.doMock("react-native", () => {
|
|
9
|
+
// Extend ReactNative
|
|
10
|
+
return Object.setPrototypeOf(
|
|
11
|
+
{
|
|
12
|
+
Image: {
|
|
13
|
+
...ReactNative.Image,
|
|
14
|
+
resolveAssetSource: jest.fn((_source) => mockFile), // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
+
getSize: jest.fn(
|
|
16
|
+
(
|
|
17
|
+
uri: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
18
|
+
success: (width: number, height: number) => void,
|
|
19
|
+
failure?: (_error: any) => void, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
+
) => success(100, 100),
|
|
21
|
+
),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
ReactNative,
|
|
25
|
+
)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
jest.mock("i18next", () => ({
|
|
29
|
+
currentLocale: "en",
|
|
30
|
+
t: (key: string, params: Record<string, string>) => {
|
|
31
|
+
return `${key} ${JSON.stringify(params)}`
|
|
32
|
+
},
|
|
33
|
+
translate: (key: string, params: Record<string, string>) => {
|
|
34
|
+
return `${key} ${JSON.stringify(params)}`
|
|
35
|
+
},
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
jest.mock("expo-localization", () => ({
|
|
39
|
+
...jest.requireActual("expo-localization"),
|
|
40
|
+
getLocales: () => [{ languageTag: "en-US", textDirection: "ltr" }],
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
jest.mock("../app/i18n/index.ts", () => ({
|
|
44
|
+
i18n: {
|
|
45
|
+
isInitialized: true,
|
|
46
|
+
language: "en",
|
|
47
|
+
t: (key: string, params: Record<string, string>) => {
|
|
48
|
+
return `${key} ${JSON.stringify(params)}`
|
|
49
|
+
},
|
|
50
|
+
numberToCurrency: jest.fn(),
|
|
51
|
+
},
|
|
52
|
+
}))
|
|
53
|
+
|
|
54
|
+
declare const tron // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
55
|
+
|
|
56
|
+
declare global {
|
|
57
|
+
let __TEST__: boolean
|
|
58
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "expo/tsconfig.base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowJs": false,
|
|
5
|
+
"allowSyntheticDefaultImports": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"jsx": "react-native",
|
|
8
|
+
"customConditions": [
|
|
9
|
+
"react-native"
|
|
10
|
+
],
|
|
11
|
+
"module": "esnext",
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noImplicitAny": true,
|
|
15
|
+
"noImplicitReturns": true,
|
|
16
|
+
"noImplicitThis": true,
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"target": "esnext",
|
|
19
|
+
"lib": [
|
|
20
|
+
"esnext",
|
|
21
|
+
"dom"
|
|
22
|
+
],
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
"resolveJsonModule": true,
|
|
25
|
+
"baseUrl": ".",
|
|
26
|
+
"paths": {
|
|
27
|
+
"@/*": [
|
|
28
|
+
"./app/*"
|
|
29
|
+
],
|
|
30
|
+
"@assets/*": [
|
|
31
|
+
"./assets/*"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"typeRoots": [
|
|
35
|
+
"./node_modules/@types",
|
|
36
|
+
"./types"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"ts-node": {
|
|
40
|
+
"compilerOptions": {
|
|
41
|
+
"module": "commonjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"include": [
|
|
45
|
+
"**/*.ts",
|
|
46
|
+
"**/*.tsx"
|
|
47
|
+
],
|
|
48
|
+
"exclude": [
|
|
49
|
+
"node_modules",
|
|
50
|
+
"test/**/*"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixes https://github.com/microsoft/TypeScript/issues/16655 for `Array.prototype.filter()`
|
|
3
|
+
* For example, using the fix the type of `bar` is `string[]` in the below snippet as it should be.
|
|
4
|
+
*
|
|
5
|
+
* const foo: (string | null | undefined)[] = [];
|
|
6
|
+
* const bar = foo.filter(Boolean);
|
|
7
|
+
*
|
|
8
|
+
* For related definitions, see https://github.com/microsoft/TypeScript/blob/master/src/lib/es5.d.ts
|
|
9
|
+
*
|
|
10
|
+
* Original licenses apply, see
|
|
11
|
+
* - https://github.com/microsoft/TypeScript/blob/master/LICENSE.txt
|
|
12
|
+
* - https://stackoverflow.com/help/licensing
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** See https://stackoverflow.com/a/51390763/1470607 */
|
|
16
|
+
type Falsy = false | 0 | "" | null | undefined
|
|
17
|
+
|
|
18
|
+
interface Array<T> {
|
|
19
|
+
/**
|
|
20
|
+
* Returns the elements of an array that meet the condition specified in a callback function.
|
|
21
|
+
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
|
|
22
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
|
23
|
+
*/
|
|
24
|
+
filter<S extends T>(predicate: BooleanConstructor, thisArg?: any): Exclude<S, Falsy>[]
|
|
25
|
+
}
|