completion

This commit is contained in:
2025-08-06 13:49:11 +08:00
commit c2d7317897
684 changed files with 92987 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/* global jest: true */
jest.mock('@react-native-community/async-storage', () => ({
getItem: () => Promise.resolve(),
setItem: () => Promise.resolve(),
mergeItem: () => Promise.resolve(),
removeItem: () => Promise.resolve(),
}));

View File

@@ -0,0 +1,11 @@
/* global jest: true */
const geolocation = {
setRNConfiguration: jest.fn(() => {}),
getCurrentPosition: jest.fn(() => {}),
watchPosition: jest.fn(() => {}),
clearWatch: jest.fn(() => {}),
stopObserving: jest.fn(() => {}),
};
export default geolocation;

View File

@@ -0,0 +1,35 @@
/* global jest: false */
import { NativeModules } from 'react-native';
jest.mock('@react-native-community/google-signin', () => {
const mockGoogleSignin = require.requireActual('@react-native-community/google-signin');
mockGoogleSignin.GoogleSignin.hasPlayServices = () => Promise.resolve(true);
mockGoogleSignin.GoogleSignin.configure = () => Promise.resolve();
mockGoogleSignin.GoogleSignin.currentUserAsync = () => Promise.resolve({
name: 'name',
email: 'test@example.com',
// .... other user data
});
// ... and other functions you want to mock
return mockGoogleSignin;
});
NativeModules.RNGoogleSignin = {
BUTTON_SIZE_ICON: 0,
BUTTON_SIZE_STANDARD: 0,
BUTTON_SIZE_WIDE: 0,
BUTTON_COLOR_AUTO: 0,
BUTTON_COLOR_LIGHT: 0,
BUTTON_COLOR_DARK: 0,
SIGN_IN_CANCELLED: '0',
IN_PROGRESS: '1',
PLAY_SERVICES_NOT_AVAILABLE: '2',
SIGN_IN_REQUIRED: '3',
configure: jest.fn(),
currentUserAsync: jest.fn(),
};
export { NativeModules };

View File

@@ -0,0 +1,7 @@
/* global jest: true */
jest.mock('@react-native-community/netinfo', () => ({
getConnectionInfo: () => Promise.resolve(),
addEventListener: jest.fn(),
isConnected: jest.fn(),
}));

View File

@@ -0,0 +1,5 @@
/* global jest: true */
jest.mock('@react-native-community/push-notification-ios', () => ({
}));

View File

@@ -0,0 +1,9 @@
// __mocks__/react-native-config.js
export default {
FOO_BAR: 'baz',
FILE_SIZE_LIMIT: 20000000,
MAX_WIDTH: 1820,
MAX_HEIGHT: 1820,
DEFAULT_VIDEO_LENGTH: 15,
DEFAULT_MIN_VIDEO_LENGTH: 3,
};

View File

@@ -0,0 +1,16 @@
/* global jest: false */
import { NativeModules } from 'react-native';
NativeModules.RNCreedonImagepicker = {
assets: jest.fn(),
launchImageLibrary: jest.fn(),
cleanupTempFiles: jest.fn(),
addListener: jest.fn(),
};
const mockRNCreedonImagepicker = jest.genMockFromModule('react-native-creedon-imagepicker');
mockRNCreedonImagepicker.assets = () => Promise.resolve();
mockRNCreedonImagepicker.launchImageLibrary = () => Promise.resolve();
mockRNCreedonImagepicker.cleanupTempFiles = () => Promise.resolve();
module.exports = mockRNCreedonImagepicker;

View File

@@ -0,0 +1,12 @@
/* global jest: true */
const deviceInfo = {
getVersion: () => '1.0.0',
getBuildNumber: () => '100',
getUniqueID: () => '0',
getDeviceId: () => '0',
getModel: () => 'model',
getIPAddress: jest.fn(),
// add more methods as needed
};
export default deviceInfo;

View File

@@ -0,0 +1,14 @@
/* global jest: true */
const firebase = {
messaging: jest.fn(() => ({
hasPermission: jest.fn(() => new Promise(resolve => resolve(true))),
})),
analytics: jest.fn(() => ({
logEvent: jest.fn(),
setUserId: jest.fn(),
setUserProperties: jest.fn(),
})),
};
export default firebase;

View File

@@ -0,0 +1,44 @@
/* global jest: true */
jest.mock('react-native-fs', () => Promise.resolve({
mkdir: jest.fn(),
moveFile: jest.fn(),
copyFile: jest.fn(),
pathForBundle: jest.fn(),
pathForGroup: jest.fn(),
getFSInfo: jest.fn(),
getAllExternalFilesDirs: jest.fn(),
unlink: jest.fn(),
exists: jest.fn(),
stopDownload: jest.fn(),
resumeDownload: jest.fn(),
isResumable: jest.fn(),
stopUpload: jest.fn(),
completeHandlerIOS: jest.fn(),
readDir: jest.fn(),
readDirAssets: jest.fn(),
existsAssets: jest.fn(),
readdir: jest.fn(),
setReadable: jest.fn(),
stat: jest.fn(),
readFile: jest.fn(),
read: jest.fn(),
readFileAssets: jest.fn(),
hash: jest.fn(),
copyFileAssets: jest.fn(),
copyFileAssetsIOS: jest.fn(),
copyAssetsVideoIOS: jest.fn(),
writeFile: jest.fn(),
appendFile: jest.fn(),
write: jest.fn(),
downloadFile: jest.fn(),
uploadFiles: jest.fn(),
touch: jest.fn(),
MainBundlePath: jest.fn(),
CachesDirectoryPath: jest.fn(),
DocumentDirectoryPath: jest.fn(),
ExternalDirectoryPath: jest.fn(),
ExternalStorageDirectoryPath: jest.fn(),
TemporaryDirectoryPath: jest.fn(),
LibraryDirectoryPath: jest.fn(),
PicturesDirectoryPath: jest.fn(),
}));

View File

@@ -0,0 +1,14 @@
/* global jest: false */
jest.mock('NativeModules', () => ({
UIManager: {
RCTView: () => {},
},
RNGestureHandlerModule: {
attachGestureHandler: jest.fn(),
createGestureHandler: jest.fn(),
dropGestureHandler: jest.fn(),
updateGestureHandler: jest.fn(),
State: {},
Directions: {},
},
}));

View File

@@ -0,0 +1,35 @@
/* global jest: false */
import { NativeModules } from 'react-native';
jest.mock('@react-native-community/google-signin', () => {
const mockGoogleSignin = require.requireActual('@react-native-community/google-signin');
mockGoogleSignin.GoogleSignin.hasPlayServices = () => Promise.resolve(true);
mockGoogleSignin.GoogleSignin.configure = () => Promise.resolve();
mockGoogleSignin.GoogleSignin.currentUserAsync = () => Promise.resolve({
name: 'name',
email: 'test@example.com',
// .... other user data
});
// ... and other functions you want to mock
return mockGoogleSignin;
});
NativeModules.RNGoogleSignin = {
BUTTON_SIZE_ICON: 0,
BUTTON_SIZE_STANDARD: 0,
BUTTON_SIZE_WIDE: 0,
BUTTON_COLOR_AUTO: 0,
BUTTON_COLOR_LIGHT: 0,
BUTTON_COLOR_DARK: 0,
SIGN_IN_CANCELLED: '0',
IN_PROGRESS: '1',
PLAY_SERVICES_NOT_AVAILABLE: '2',
SIGN_IN_REQUIRED: '3',
configure: jest.fn(),
currentUserAsync: jest.fn(),
};
export { NativeModules };

View File

@@ -0,0 +1,15 @@
/* global jest: false */
jest.mock('react-native-haptic-feedback', () => ({
trigger: jest.fn(),
}));
// import { NativeModules } from 'react-native';
// NativeModules.RNReactNativeHapticFeedback = {
// trigger: jest.fn(),
// };
// const ReactNativeHapticFeedback = jest.genMockFromModule('react-native-haptic-feedback');
// module.exports = ReactNativeHapticFeedback;

View File

@@ -0,0 +1,5 @@
/* global jest: false */
export const setGenericPassword = () => jest.fn();
export const getGenericPassword = () => jest.fn(Promise.resolve(''));
export const resetGenericPassword = () => jest.fn();

View File

@@ -0,0 +1,60 @@
/* global jest: true */
// https://github.com/react-native-community/react-native-localize/blob/master/README.md#how-to-test-your-code
const getLocales = () => [
// you can choose / add the locales you want
{
countryCode: 'US',
languageTag: 'en',
languageCode: 'en',
isRTL: false,
},
{
countryCode: 'DE',
languageTag: 'de',
languageCode: 'de',
isRTL: false,
},
{
countryCode: 'JA',
languageTag: 'ja',
languageCode: 'ja',
isRTL: false,
},
];
// use a provided translation, or return undefined to test your fallback
const findBestAvailableLanguage = () => ({
languageTag: 'en',
isRTL: false,
});
const getNumberFormatSettings = () => ({
decimalSeparator: '.',
groupingSeparator: ',',
});
const getCalendar = () => 'gregorian'; // or 'japanese', 'buddhist'
const getCountry = () => 'US'; // the country code you want
const getCurrencies = () => ['USD', 'EUR']; // can be empty array
const getTemperatureUnit = () => 'celsius'; // or 'fahrenheit'
const getTimeZone = () => 'Europe/Paris'; // the timezone you want
const uses24HourClock = () => true;
const usesMetricSystem = () => true;
const addEventListener = jest.fn();
const removeEventListener = jest.fn();
export {
findBestAvailableLanguage,
getLocales,
getNumberFormatSettings,
getCalendar,
getCountry,
getCurrencies,
getTemperatureUnit,
getTimeZone,
uses24HourClock,
usesMetricSystem,
addEventListener,
removeEventListener,
};

View File

@@ -0,0 +1,10 @@
/* global jest: true */
const NixplayCore = jest.genMockFromModule('react-native-nixplay-core');
NixplayCore.setUploadSessionIdentifier = () => Promise.resolve();
NixplayCore.setApiURL = () => Promise.resolve();
NixplayCore.setBucketPrefix = () => Promise.resolve();
NixplayCore.setFileSizeLimit = () => Promise.resolve();
NixplayCore.startUpload = () => Promise.resolve();
export default NixplayCore;

View File

@@ -0,0 +1,13 @@
/* global jest: true */
const PushNotification = jest.genMockFromModule('react-native-push-notification');
PushNotification.configure = jest.fn();
PushNotification.onRegister = jest.fn();
PushNotification.onNotification = jest.fn();
PushNotification.addEventListener = jest.fn();
PushNotification.requestPermissions = jest.fn();
PushNotification.cancelAllLocalNotifications = jest.fn();
PushNotification.setApplicationIconBadgeNumber = jest.fn();
export default PushNotification;

View File

@@ -0,0 +1,3 @@
const NativeEventEmitter = {};
export default NativeEventEmitter;

View File

@@ -0,0 +1,14 @@
/* global jest: true */
const SafeArea = {};
SafeArea.getSafeAreaInsetsForRootView = () => ({
safeAreaInsets: {
top: 0,
bottom: 0,
left: 0,
right: 0,
},
});
SafeArea.addEventListener = jest.fn();
export default SafeArea;

View File

@@ -0,0 +1,7 @@
/* global jest: true */
const ShareExtension = {
data: jest.fn(() => Promise.resolve({})),
close: jest.fn(() => Promise.resolve(true)),
};
export default ShareExtension;

View File

@@ -0,0 +1,8 @@
/* global jest: true */
const FilesystemStorage = {
getItem: jest.fn(() => Promise.resolve()),
setItem: jest.fn(() => Promise.resolve()),
};
export default FilesystemStorage;