Files
iNaturalistReactNative/__mocks__/react-native-fs.ts
Johannes Klein 5c8e3be12c test AI camera in e2e (#2188)
* Add a cameraZoomRange default
* Small detox version bump
* Add a mocked camera with a take photo button
* An e2e mock for the computer vision plugin predicting a frame
* Mock taking a photo by loading the first photo from the CameraRoll

Closes #1981
2024-11-01 10:38:37 -07:00

34 lines
966 B
TypeScript

const mockFs = require( "fs" );
module.exports = {
appendFile: jest.fn( ),
CachesDirectoryPath: "caches/directory/path",
DocumentDirectoryPath: "document/directory/path",
exists: jest.fn( async ( ) => true ),
moveFile: async ( ) => "testdata",
copyFile: async ( ) => "testdata",
copyAssetsFileIOS: async ( ) => "testdata",
stat: jest.fn( ( ) => ( {
mtime: new Date()
} ) ),
readFile: jest.fn( ( ) => "testdata" ),
readDir: jest.fn( async ( ) => ( [
{
ctime: new Date(),
mtime: new Date(),
name: "testdata"
}
] ) ),
writeFile: jest.fn( async ( filePath, contents, _encoding ) => {
mockFs.writeFile( filePath, contents, jest.fn( ) );
} ),
mkdir: jest.fn( async ( filepath, _options ) => {
mockFs.mkdir( filepath, jest.fn( ) );
} ),
unlink: jest.fn( async ( path = "" ) => {
if ( !path ) return;
if ( typeof ( path ) !== "string" ) return;
mockFs.unlink( path, jest.fn( ) );
} )
};