mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
Add unit and integration tests around sharing photos (#2948)
This commit is contained in:
committed by
GitHub
parent
3faf5e3e29
commit
5eb77e91fd
@@ -1,6 +1,31 @@
|
||||
// Trivial mock b/c I assume we can't really test the native parts of this
|
||||
// library ~~~kueda 20230516
|
||||
export default ( {
|
||||
addNewShareListener: jest.fn( ),
|
||||
getInitialShare: jest.fn( )
|
||||
} );
|
||||
let mockShareData = null;
|
||||
let mockListeners = [];
|
||||
|
||||
const ShareMenu = {
|
||||
getInitialShare: jest.fn( callback => {
|
||||
if ( mockShareData ) {
|
||||
callback( mockShareData );
|
||||
}
|
||||
} ),
|
||||
|
||||
addNewShareListener: jest.fn( callback => {
|
||||
const listener = { callback, remove: jest.fn() };
|
||||
mockListeners.push( listener );
|
||||
return listener;
|
||||
} ),
|
||||
|
||||
__setMockShareData: data => {
|
||||
mockShareData = data;
|
||||
},
|
||||
|
||||
__triggerNewShare: data => {
|
||||
mockListeners.forEach( listener => listener.callback( data ) );
|
||||
},
|
||||
|
||||
__reset: ( ) => {
|
||||
mockShareData = null;
|
||||
mockListeners = [];
|
||||
}
|
||||
};
|
||||
|
||||
export default ShareMenu;
|
||||
|
||||
Reference in New Issue
Block a user