first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

27
node_modules/react-native/jest/MockNativeMethods.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const MockNativeMethods = {
measure: jest.fn(),
measureInWindow: jest.fn(),
measureLayout: jest.fn(),
setNativeProps: jest.fn(),
focus: jest.fn(),
blur: jest.fn(),
} as {
measure: () => void,
measureInWindow: () => void,
measureLayout: () => void,
setNativeProps: () => void,
focus: () => void,
blur: () => void,
};
export default MockNativeMethods;

32
node_modules/react-native/jest/RefreshControlMock.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import type {HostComponent} from '../src/private/types/HostComponent';
import requireNativeComponent from '../Libraries/ReactNative/requireNativeComponent';
import * as React from 'react';
const RCTRefreshControl: HostComponent<{}> = requireNativeComponent<{}>(
'RCTRefreshControl',
);
export default class RefreshControlMock extends React.Component<{...}> {
static latestRef: ?RefreshControlMock;
render(): React.Node {
return <RCTRefreshControl />;
}
componentDidMount() {
RefreshControlMock.latestRef = this;
}
}

33
node_modules/react-native/jest/assetFileTransformer.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
* @format
*/
'use strict';
/* eslint-env node */
const createCacheKeyFunction =
require('@jest/create-cache-key-function').default;
const path = require('path');
module.exports = {
// Mocks asset requires to return the filename. Makes it possible to test that
// the correct images are loaded for components. Essentially
// require('img1.png') becomes `Object { "testUri": 'path/to/img1.png' }` in
// the Jest snapshot.
process: (_, filename) => ({
code: `module.exports = {
testUri:
${JSON.stringify(
path.relative(__dirname, filename).replace(/\\/g, '/'),
)}
};`,
}),
getCacheKey: createCacheKeyFunction([__filename]),
};

29
node_modules/react-native/jest/local-setup.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
// Global setup for tests local to the react-native repo. This setup is not
// included in the react-native Jest preset.
import './setup';
const consoleError = console.error;
const consoleWarn = console.warn;
// $FlowFixMe[cannot-write]
console.error = (...args) => {
consoleError(...args);
throw new Error('console.error() was called (see error above)');
};
// $FlowFixMe[cannot-write]
console.warn = (...args) => {
consoleWarn(...args);
throw new Error('console.warn() was called (see warning above)');
};

39
node_modules/react-native/jest/mock.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
* @oncall react_native
*/
/**
* Mocks the module referenced by `moduleRef` (expected to begin with `m#`)
* while enforcing type safety of mock factories.
*
* If `factoryRef` is provided, it is expected to reference a module that
* exports the same type signature as the module referenced by `moduleRef`.
*/
export default function mock<TModuleRef: $Flow$ModuleRef<mixed>>(
moduleRef: TModuleRef,
factoryRef?: NoInfer<TModuleRef>,
): void {
// NOTE: Jest's `babel-plugin-jest-hoist` requires that the second argument to
// `jest.mock` be an inline function, so structure this code accordingly.
if (factoryRef === undefined) {
jest.mock(deref(moduleRef));
} else {
// NOTE: Jest's `babel-plugin-jest-hoist` requires that module factories
// only reference local variables or variables starting with "mock", so be
// careful when renaming this `mockFactory` variable.
const mockFactory = deref(factoryRef);
jest.mock(deref(moduleRef), () => jest.requireActual(mockFactory));
}
}
function deref(ref: $Flow$ModuleRef<mixed>): string {
// $FlowFixMe[incompatible-type]
return (ref as string).substring(2);
}

104
node_modules/react-native/jest/mockComponent.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import * as React from 'react';
import {createElement} from 'react';
type Modulish<T> = T | $ReadOnly<{default: T}>;
type ModuleDefault<T> = T['default'];
type TComponentType = React.ComponentType<{...}>;
/**
* WARNING: The `moduleName` must be relative to this file's directory, which is
* a major footgun. Be careful when using this function!
*/
export default function mockComponent<
TComponentModule: Modulish<TComponentType>,
TIsESModule: boolean,
>(
moduleName: string,
instanceMethods: ?interface {},
isESModule: TIsESModule,
): TIsESModule extends true
? // $FlowFixMe[incompatible-use]
ModuleDefault<TComponentModule & typeof instanceMethods>
: TComponentModule & typeof instanceMethods {
const RealComponent: TComponentType = isESModule
? // $FlowFixMe[prop-missing]
jest.requireActual<TComponentModule>(moduleName).default
: // $FlowFixMe[incompatible-type]
jest.requireActual<TComponentModule>(moduleName);
const SuperClass: typeof React.Component<{...}> =
typeof RealComponent === 'function' &&
RealComponent.prototype.constructor instanceof React.Component
? RealComponent
: React.Component;
const name =
RealComponent.displayName ??
RealComponent.name ??
// $FlowFixMe[prop-missing] - Checking for `forwardRef` values.
(RealComponent.render == null
? 'Unknown'
: // $FlowFixMe[incompatible-use]
(RealComponent.render.displayName ?? RealComponent.render.name));
const nameWithoutPrefix = name.replace(/^(RCT|RK)/, '');
const Component = class extends SuperClass {
static displayName: ?string = 'Component';
render(): React.Node {
// $FlowFixMe[prop-missing]
const props = {...RealComponent.defaultProps};
if (this.props) {
Object.keys(this.props).forEach(prop => {
// We can't just assign props on top of defaultProps
// because React treats undefined as special and different from null.
// If a prop is specified but set to undefined it is ignored and the
// default prop is used instead. If it is set to null, then the
// null value overwrites the default value.
if (this.props[prop] !== undefined) {
props[prop] = this.props[prop];
}
});
}
// $FlowFixMe[not-a-function]
// $FlowFixMe[prop-missing]
return createElement(nameWithoutPrefix, props, this.props.children);
}
};
Object.defineProperty(Component, 'name', {
value: name,
writable: false,
enumerable: false,
configurable: true,
});
Component.displayName = nameWithoutPrefix;
// $FlowFixMe[not-an-object]
Object.keys(RealComponent).forEach(classStatic => {
Component[classStatic] = RealComponent[classStatic];
});
if (instanceMethods != null) {
// $FlowFixMe[unsafe-object-assign]
Object.assign(Component.prototype, instanceMethods);
}
// $FlowFixMe[incompatible-type]
return Component;
}

52
node_modules/react-native/jest/mockNativeComponent.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import type {HostInstance} from '../src/private/types/HostInstance';
import * as React from 'react';
import {createElement} from 'react';
let nativeTag = 1;
type MockNativeComponent<TProps: {...}> = component(
ref?: ?React.RefSetter<HostInstance>,
...props: TProps
);
export default function mockNativeComponent<TProps: {...}>(
viewName: string,
): MockNativeComponent<TProps> {
const Component = class extends React.Component<TProps> {
_nativeTag: number = nativeTag++;
render(): React.Node {
// $FlowFixMe[not-a-function]
// $FlowFixMe[prop-missing]
return createElement(viewName, this.props, this.props.children);
}
// The methods that exist on host components
blur: () => void = jest.fn();
focus: () => void = jest.fn();
measure: () => void = jest.fn();
measureInWindow: () => void = jest.fn();
measureLayout: () => void = jest.fn();
setNativeProps: () => void = jest.fn();
};
if (viewName === 'RCTView') {
Component.displayName = 'View';
} else {
Component.displayName = viewName;
}
// $FlowFixMe[incompatible-type] - Error supressed during the migration of HostInstance to ReactNativeElement
return Component;
}

View File

@@ -0,0 +1,62 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const AccessibilityInfo = {
addEventListener: jest.fn(() => ({
remove: jest.fn(),
})) as JestMockFn<$FlowFixMe, {remove: JestMockFn<[], void>}>,
announceForAccessibility: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
announceForAccessibilityWithOptions: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
isAccessibilityServiceEnabled: jest.fn(() =>
Promise.resolve(false),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
isBoldTextEnabled: jest.fn(() => Promise.resolve(false)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
isGrayscaleEnabled: jest.fn(() => Promise.resolve(false)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
isInvertColorsEnabled: jest.fn(() => Promise.resolve(false)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
isReduceMotionEnabled: jest.fn(() => Promise.resolve(false)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
isHighTextContrastEnabled: jest.fn(() =>
Promise.resolve(false),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
isDarkerSystemColorsEnabled: jest.fn(() =>
Promise.resolve(false),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
prefersCrossFadeTransitions: jest.fn(() =>
Promise.resolve(false),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
isReduceTransparencyEnabled: jest.fn(() =>
Promise.resolve(false),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
isScreenReaderEnabled: jest.fn(() => Promise.resolve(false)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
setAccessibilityFocus: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
sendAccessibilityEvent: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
getRecommendedTimeoutMillis: jest.fn(() =>
Promise.resolve(false),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
};
export default AccessibilityInfo;

View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import typeof TActivityIndicator from '../../Libraries/Components/ActivityIndicator/ActivityIndicator';
import typeof * as TmockComponent from '../mockComponent';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
const ActivityIndicator = mockComponent(
'../Libraries/Components/ActivityIndicator/ActivityIndicator',
null, // instanceMethods
true, // isESModule
) as TActivityIndicator;
export default ActivityIndicator;

19
node_modules/react-native/jest/mocks/AppState.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const AppState = {
addEventListener: jest.fn(() => ({
remove: jest.fn(),
})) as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeEventListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
currentState: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
};
export default AppState;

16
node_modules/react-native/jest/mocks/Clipboard.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const Clipboard = {
getString: jest.fn(async () => '') as JestMockFn<[], Promise<string>>,
setString: jest.fn() as JestMockFn<[string], void>,
};
export default Clipboard;

23
node_modules/react-native/jest/mocks/Image.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import typeof TImage from '../../Libraries/Image/Image';
import typeof * as TmockComponent from '../mockComponent';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
const Image = mockComponent(
'../Libraries/Image/Image',
null, // instanceMethods
true, // isESModule
) as TImage;
export default Image;

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/

28
node_modules/react-native/jest/mocks/Linking.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const Linking = {
openURL: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
canOpenURL: jest.fn(() => Promise.resolve(true)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
openSettings: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
addEventListener: jest.fn(() => ({
remove: jest.fn(),
})) as JestMockFn<$FlowFixMe, $FlowFixMe>,
getInitialURL: jest.fn(() => Promise.resolve()) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
sendIntent: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
};
export default Linking;

33
node_modules/react-native/jest/mocks/Modal.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {ModalProps} from '../../Libraries/Modal/Modal';
import typeof * as TmockComponent from '../mockComponent';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
type TModal = component(...ModalProps);
const BaseComponent = mockComponent(
'../Libraries/Modal/Modal',
null, // instanceMethods
true, // isESModule
) as TModal;
// $FlowFixMe[incompatible-use]
export default class Modal extends BaseComponent {
render(): React.Node {
if (this.props.visible === false) {
return null;
}
return <BaseComponent {...this.props}>{this.props.children}</BaseComponent>;
}
}

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import typeof * as TmockNativeComponent from '../mockNativeComponent';
const mockNativeComponent = jest.requireActual<TmockNativeComponent>(
'../mockNativeComponent',
).default;
export const get = jest.fn((name, viewConfigProvider) => {
return mockNativeComponent(name);
}) as JestMockFn<$FlowFixMe, $FlowFixMe>;
export const getWithFallback_DEPRECATED = jest.fn(
(name, viewConfigProvider) => {
return mockNativeComponent(name);
},
) as JestMockFn<$FlowFixMe, $FlowFixMe>;
export const setRuntimeConfigProvider = jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>;

239
node_modules/react-native/jest/mocks/NativeModules.js generated vendored Normal file
View File

@@ -0,0 +1,239 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
// TODO: Split this up into separate files.
const NativeModules = {
AlertManager: {
alertWithArgs: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
AsyncLocalStorage: {
multiGet: jest.fn((keys, callback) =>
process.nextTick(() => callback(null, [])),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
multiSet: jest.fn((entries, callback) =>
process.nextTick(() => callback(null)),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
multiRemove: jest.fn((keys, callback) =>
process.nextTick(() => callback(null)),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
multiMerge: jest.fn((entries, callback) =>
process.nextTick(() => callback(null)),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
clear: jest.fn(callback =>
process.nextTick(() => callback(null)),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
getAllKeys: jest.fn(callback =>
process.nextTick(() => callback(null, [])),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
DeviceInfo: {
getConstants(): $FlowFixMe {
return {
Dimensions: {
window: {
fontScale: 2,
height: 1334,
scale: 2,
width: 750,
},
screen: {
fontScale: 2,
height: 1334,
scale: 2,
width: 750,
},
},
};
},
},
DevSettings: {
addMenuItem: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
reload: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
ImageLoader: {
getSize: jest.fn(url => Promise.resolve([320, 240])) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
getSizeWithHeaders: jest.fn((url, headers) =>
Promise.resolve({height: 222, width: 333}),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
prefetchImage: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
prefetchImageWithMetadata: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
queryCache: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
ImageViewManager: {
getSize: jest.fn((uri, success) =>
process.nextTick(() => success(320, 240)),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
prefetchImage: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
KeyboardObserver: {
addListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeListeners: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
NativeAnimatedModule: {
createAnimatedNode: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
updateAnimatedNodeConfig: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
getValue: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
startListeningToAnimatedNodeValue: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
stopListeningToAnimatedNodeValue: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
connectAnimatedNodes: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
disconnectAnimatedNodes: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
startAnimatingNode: jest.fn((animationId, nodeTag, config, endCallback) => {
setTimeout(() => endCallback({finished: true}), 16);
}) as JestMockFn<$FlowFixMe, $FlowFixMe>,
stopAnimation: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setAnimatedNodeValue: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setAnimatedNodeOffset: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
flattenAnimatedNodeOffset: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
extractAnimatedNodeOffset: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
connectAnimatedNodeToView: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
disconnectAnimatedNodeFromView: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
restoreDefaultValues: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
dropAnimatedNode: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
addAnimatedEventToView: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeAnimatedEventFromView: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
addListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeListeners: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
Networking: {
sendRequest: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
abortRequest: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
addListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeListeners: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
PlatformConstants: {
getConstants(): $FlowFixMe {
return {
reactNativeVersion: {
major: 1000,
minor: 0,
patch: 0,
prerelease: undefined,
},
};
},
},
PushNotificationManager: {
presentLocalNotification: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
scheduleLocalNotification: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
cancelAllLocalNotifications: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
removeAllDeliveredNotifications: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
getDeliveredNotifications: jest.fn(callback =>
process.nextTick(() => []),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeDeliveredNotifications: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
setApplicationIconBadgeNumber: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
getApplicationIconBadgeNumber: jest.fn(callback =>
process.nextTick(() => callback(0)),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
cancelLocalNotifications: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
getScheduledLocalNotifications: jest.fn(callback =>
process.nextTick(() => callback()),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
requestPermissions: jest.fn(() =>
Promise.resolve({alert: true, badge: true, sound: true}),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
abandonPermissions: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
checkPermissions: jest.fn(callback =>
process.nextTick(() => callback({alert: true, badge: true, sound: true})),
) as JestMockFn<$FlowFixMe, $FlowFixMe>,
getInitialNotification: jest.fn(() => Promise.resolve(null)) as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
addListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeListeners: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
SourceCode: {
getConstants(): $FlowFixMe {
return {
scriptURL: null,
};
},
},
StatusBarManager: {
setColor: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setStyle: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setHidden: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setNetworkActivityIndicatorVisible: jest.fn() as JestMockFn<
$FlowFixMe,
$FlowFixMe,
>,
setBackgroundColor: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setTranslucent: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
getConstants: (): $FlowFixMe => ({
HEIGHT: 42,
}),
},
Timing: {
createTimer: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
deleteTimer: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
UIManager: {},
BlobModule: {
getConstants: (): $FlowFixMe => ({
BLOB_URI_SCHEME: 'content',
BLOB_URI_HOST: null,
}),
addNetworkingHandler: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
enableBlobSupport: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
disableBlobSupport: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
createFromParts: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
sendBlob: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
release: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
WebSocketModule: {
connect: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
send: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
sendBinary: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
ping: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
close: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
addListener: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
removeListeners: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
I18nManager: {
allowRTL: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
forceRTL: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
swapLeftAndRightInRTL: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
getConstants: (): $FlowFixMe => ({
isRTL: false,
doLeftAndRightSwapInRTL: true,
}),
},
};
export default NativeModules;

31
node_modules/react-native/jest/mocks/RefreshControl.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {RefreshControlProps} from '../../Libraries/Components/RefreshControl/RefreshControl';
import type {HostComponent} from '../../src/private/types/HostComponent';
import requireNativeComponent from '../../Libraries/ReactNative/requireNativeComponent';
import * as React from 'react';
const RCTRefreshControl: HostComponent<{}> = requireNativeComponent<{}>(
'RCTRefreshControl',
);
export default class RefreshControlMock extends React.Component<RefreshControlProps> {
static latestRef: ?RefreshControlMock;
render(): React.Node {
return <RCTRefreshControl />;
}
componentDidMount() {
RefreshControlMock.latestRef = this;
}
}

45
node_modules/react-native/jest/mocks/RendererProxy.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
// In tests, we can use the default version without dependency injection.
import typeof * as TRendererImplementation from '../../Libraries/ReactNative/RendererImplementation';
const {
dispatchCommand,
findHostInstance_DEPRECATED,
findNodeHandle,
getNodeFromInternalInstanceHandle,
getPublicInstanceFromInternalInstanceHandle,
getPublicInstanceFromRootTag,
isChildPublicInstance,
isProfilingRenderer,
renderElement,
sendAccessibilityEvent,
unmountComponentAtNodeAndRemoveContainer,
unstable_batchedUpdates,
} = jest.requireActual<TRendererImplementation>(
'../../Libraries/ReactNative/RendererImplementation',
) as TRendererImplementation;
export {
dispatchCommand,
findHostInstance_DEPRECATED,
findNodeHandle,
getNodeFromInternalInstanceHandle,
getPublicInstanceFromInternalInstanceHandle,
getPublicInstanceFromRootTag,
isChildPublicInstance,
isProfilingRenderer,
renderElement,
sendAccessibilityEvent,
unmountComponentAtNodeAndRemoveContainer,
unstable_batchedUpdates,
};

58
node_modules/react-native/jest/mocks/ScrollView.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import typeof TScrollView from '../../Libraries/Components/ScrollView/ScrollView';
import type {ScrollViewNativeProps} from '../../Libraries/Components/ScrollView/ScrollViewNativeComponentType';
import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
import View from '../../Libraries/Components/View/View';
import requireNativeComponent from '../../Libraries/ReactNative/requireNativeComponent';
import * as React from 'react';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
const MockNativeMethods = jest.requireActual<TMockNativeMethods>(
'../MockNativeMethods',
).default;
const RCTScrollView =
requireNativeComponent<ScrollViewNativeProps>('RCTScrollView');
const BaseComponent = mockComponent(
'../Libraries/Components/ScrollView/ScrollView',
{
...MockNativeMethods,
getScrollResponder: jest.fn(),
getScrollableNode: jest.fn(),
getInnerViewNode: jest.fn(),
getInnerViewRef: jest.fn(),
getNativeScrollRef: jest.fn(),
scrollTo: jest.fn(),
scrollToEnd: jest.fn(),
flashScrollIndicators: jest.fn(),
scrollResponderZoomTo: jest.fn(),
scrollResponderScrollNativeHandleToKeyboard: jest.fn(),
}, // instanceMethods
true, // isESModule
) as TScrollView;
// $FlowFixMe[incompatible-type]
// $FlowFixMe[invalid-exported-annotation]
export default class ScrollViewMock extends BaseComponent {
render(): React.Node {
return (
<RCTScrollView {...this.props}>
{this.props.refreshControl}
<View>{this.props.children}</View>
</RCTScrollView>
);
}
}

27
node_modules/react-native/jest/mocks/Text.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import typeof TText from '../../Libraries/Text/Text';
import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
const MockNativeMethods = jest.requireActual<TMockNativeMethods>(
'../MockNativeMethods',
).default;
const Text = mockComponent(
'../Libraries/Text/Text',
MockNativeMethods, // instanceMethods
true, // isESModule
) as TText;
export default Text;

32
node_modules/react-native/jest/mocks/TextInput.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import typeof TTextInput from '../../Libraries/Components/TextInput/TextInput';
import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
const MockNativeMethods = jest.requireActual<TMockNativeMethods>(
'../MockNativeMethods',
).default;
const TextInput = mockComponent(
'../Libraries/Components/TextInput/TextInput',
{
...MockNativeMethods,
isFocused: jest.fn(),
clear: jest.fn(),
getNativeRef: jest.fn(),
}, // instanceMethods
true, // isESModule
) as TTextInput;
export default TextInput;

60
node_modules/react-native/jest/mocks/UIManager.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const UIManager = {
AndroidViewPager: {
Commands: {
setPage: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setPageWithoutAnimation: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
},
},
blur: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
createView: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
customBubblingEventTypes: {},
customDirectEventTypes: {},
dispatchViewManagerCommand: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
focus: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
getViewManagerConfig: jest.fn(name => {
if (name === 'AndroidDrawerLayout') {
return {
Constants: {
DrawerPosition: {
Left: 10,
},
},
};
}
}) as JestMockFn<[string], $FlowFixMe>,
hasViewManagerConfig: jest.fn(name => {
return name === 'AndroidDrawerLayout';
}) as JestMockFn<[string], boolean>,
measure: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
manageChildren: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
setChildren: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
updateView: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
AndroidDrawerLayout: {
Constants: {
DrawerPosition: {
Left: 10,
},
},
},
AndroidTextInput: {
Commands: {},
},
ScrollView: {
Constants: {},
},
View: {
Constants: {},
},
};
export default UIManager;

16
node_modules/react-native/jest/mocks/Vibration.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
const Vibration = {
vibrate: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
cancel: jest.fn() as JestMockFn<$FlowFixMe, $FlowFixMe>,
};
export default Vibration;

27
node_modules/react-native/jest/mocks/View.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import typeof TView from '../../Libraries/Components/View/View';
import typeof * as TmockComponent from '../mockComponent';
import typeof * as TMockNativeMethods from '../MockNativeMethods';
const mockComponent =
jest.requireActual<TmockComponent>('../mockComponent').default;
const MockNativeMethods = jest.requireActual<TMockNativeMethods>(
'../MockNativeMethods',
).default;
const View = mockComponent(
'../Libraries/Components/View/View',
MockNativeMethods, // instanceMethods
true, // isESModule
) as TView;
export default View;

View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {ViewProps} from '../../Libraries/Components/View/ViewPropTypes';
import * as React from 'react';
import {createElement} from 'react';
export default class View extends React.Component<ViewProps> {
render(): React.Node {
// $FlowFixMe[not-a-function]
return createElement('View', this.props, this.props.children);
}
}
View.displayName = 'View';

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import type {HostComponent} from '../../src/private/types/HostComponent';
import typeof * as TmockNativeComponent from '../mockNativeComponent';
const mockNativeComponent = jest.requireActual<TmockNativeComponent>(
'../mockNativeComponent',
).default;
export default function requireNativeComponent<T: {...}>(
uiViewClassName: string,
): HostComponent<T> {
return mockNativeComponent<T>(uiViewClassName);
}

18
node_modules/react-native/jest/mocks/useColorScheme.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import type {ColorSchemeName} from '../../Libraries/Utilities/NativeAppearance';
const useColorScheme = jest.fn(() => 'light') as JestMockFn<
[],
ColorSchemeName,
>;
export default useColorScheme;

17
node_modules/react-native/jest/react-native-env.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
* @format
*/
'use strict';
const NodeEnv = require('jest-environment-node').TestEnvironment;
module.exports = class ReactNativeEnv extends NodeEnv {
customExportConditions = ['require', 'react-native'];
};

40
node_modules/react-native/jest/renderer.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
import type {ReactTestRenderer} from 'react-test-renderer';
import nullthrows from 'nullthrows';
import * as React from 'react';
import TestRenderer from 'react-test-renderer';
export async function create(
Component: React.MixedElement,
): Promise<ReactTestRenderer> {
let component;
await TestRenderer.act(async () => {
component = TestRenderer.create(Component);
});
return nullthrows(component);
}
export async function unmount(testRenderer: ReactTestRenderer) {
await TestRenderer.act(async () => {
testRenderer.unmount();
});
}
export async function update(
testRenderer: ReactTestRenderer,
element: React.MixedElement,
) {
await TestRenderer.act(async () => {
testRenderer.update(element);
});
}

32
node_modules/react-native/jest/resolver.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
* @format
*/
'use strict';
module.exports = (path, options) => {
const originalPackageFilter = options.packageFilter;
return options.defaultResolver(path, {
...options,
packageFilter: pkg => {
const filteredPkg = originalPackageFilter
? originalPackageFilter(pkg)
: pkg;
// Temporarily allow any react-native subpaths to be resolved and
// mocked by Jest (backwards compatibility around RFC0894)
if (filteredPkg.name === 'react-native') {
delete filteredPkg.exports;
}
return filteredPkg;
},
});
};

140
node_modules/react-native/jest/setup.js generated vendored Normal file
View File

@@ -0,0 +1,140 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
global.IS_REACT_ACT_ENVIRONMENT = true;
// Suppress the `react-test-renderer` warnings until New Architecture and legacy
// mode are no longer supported by React Native.
global.IS_REACT_NATIVE_TEST_ENVIRONMENT = true;
import '@react-native/js-polyfills/error-guard';
import mock from './mock';
// $FlowFixMe[cannot-write]
Object.defineProperties(global, {
__DEV__: {
configurable: true,
enumerable: true,
value: true,
writable: true,
},
cancelAnimationFrame: {
configurable: true,
enumerable: true,
value(id: TimeoutID): void {
return clearTimeout(id);
},
writable: true,
},
nativeFabricUIManager: {
configurable: true,
enumerable: true,
value: {},
writable: true,
},
performance: {
configurable: true,
enumerable: true,
value: {
// $FlowFixMe[method-unbinding]
now: jest.fn(Date.now),
},
writable: true,
},
regeneratorRuntime: {
configurable: true,
enumerable: true,
value: jest.requireActual<mixed>('regenerator-runtime/runtime'),
writable: true,
},
requestAnimationFrame: {
configurable: true,
enumerable: true,
value(callback: number => void): TimeoutID {
return setTimeout(() => callback(jest.now()), 0);
},
writable: true,
},
window: {
configurable: true,
enumerable: true,
value: global,
writable: true,
},
});
// This setup script will be published in the react-native package.
// Other people might not have prettier installed, so it will crash the mock below.
// Therefore, we wrap this mock in a try-catch.
try {
/**
* Prettier v3 uses import (cjs/mjs) file formats that jest-runtime does not
* support. To work around this we need to bypass the jest module system by
* using the orginal node `require` function.
*/
jest.mock('prettier', () => {
// $FlowExpectedError[underconstrained-implicit-instantiation]
const module = jest.requireActual('module');
return module.prototype.require(require.resolve('prettier'));
});
} catch {}
// $FlowFixMe[incompatible-type] - `./mocks/AppState` is incomplete.
mock('m#../Libraries/AppState/AppState', 'm#./mocks/AppState');
mock('m#../Libraries/BatchedBridge/NativeModules', 'm#./mocks/NativeModules');
mock(
'm#../Libraries/Components/AccessibilityInfo/AccessibilityInfo',
'm#./mocks/AccessibilityInfo',
);
mock(
'm#../Libraries/Components/ActivityIndicator/ActivityIndicator',
'm#./mocks/ActivityIndicator',
);
mock('m#../Libraries/Components/Clipboard/Clipboard', 'm#./mocks/Clipboard');
mock(
'm#../Libraries/Components/RefreshControl/RefreshControl',
// $FlowFixMe[incompatible-type] - `../Libraries/Components/RefreshControl/RefreshControl` should export a component type.
'm#./mocks/RefreshControl',
);
// $FlowFixMe[incompatible-exact] - `../Libraries/Components/ScrollView/ScrollView` is... I don't even.
// $FlowFixMe[incompatible-type]
mock('m#../Libraries/Components/ScrollView/ScrollView', 'm#./mocks/ScrollView');
mock('m#../Libraries/Components/TextInput/TextInput', 'm#./mocks/TextInput');
mock('m#../Libraries/Components/View/View', 'm#./mocks/View');
mock(
'm#../Libraries/Components/View/ViewNativeComponent',
// $FlowFixMe[incompatible-type] - `./mocks/ViewNativeComponent` is incomplete.
// $FlowFixMe[prop-missing]
'm#./mocks/ViewNativeComponent',
);
mock('m#../Libraries/Core/InitializeCore', 'm#./mocks/InitializeCore');
mock('m#../Libraries/Core/NativeExceptionsManager');
mock('m#../Libraries/Image/Image', 'm#./mocks/Image');
// $FlowFixMe[incompatible-type] - `./mocks/Linking` is incomplete.
mock('m#../Libraries/Linking/Linking', 'm#./mocks/Linking');
// $FlowFixMe[incompatible-type] - `../Libraries/Modal/Modal` should export a component type.
mock('m#../Libraries/Modal/Modal', 'm#./mocks/Modal');
mock(
'm#../Libraries/NativeComponent/NativeComponentRegistry',
// $FlowFixMe[incompatible-type] - `./mocks/NativeComponentRegistry` should export named functions.
'm#./mocks/NativeComponentRegistry',
);
// $FlowFixMe[incompatible-type] - `./mocks/RendererProxy` is incomplete.
mock('m#../Libraries/ReactNative/RendererProxy', 'm#./mocks/RendererProxy');
mock(
'm#../Libraries/ReactNative/requireNativeComponent',
'm#./mocks/requireNativeComponent',
);
// $FlowFixMe[incompatible-type] - `./mocks/UIManager` is incomplete.
mock('m#../Libraries/ReactNative/UIManager', 'm#./mocks/UIManager');
mock('m#../Libraries/Text/Text', 'm#./mocks/Text');
mock('m#../Libraries/Utilities/useColorScheme', 'm#./mocks/useColorScheme');
// $FlowFixMe[incompatible-type]
mock('m#../Libraries/Vibration/Vibration', 'm#./mocks/Vibration');