mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-20 05:28:29 -04:00
* Add zustand to app * Begin replacing ObsEditProvider with zustand for global state * Use store and add tests * Fix bugs * Add test to check for deleted photos in StandardCamera * Make sure evidence is only added to current observation; submit comment with ID on ObsDetail * Fix ObsEditWithoutProvider tests * Move store to where it's needed * Fix tests * Await evidence being added to obsPhotos from camera * Add a note about slices to useStore
25 lines
697 B
JavaScript
25 lines
697 B
JavaScript
import { renderHook } from "@testing-library/react-native";
|
|
import { useCurrentUser } from "sharedHooks";
|
|
|
|
import factory from "../../factory";
|
|
|
|
const mockUser = factory( "LocalUser", {
|
|
login: "fake_login",
|
|
signedIn: true
|
|
} );
|
|
|
|
describe( "useCurrentUser", () => {
|
|
beforeEach( async ( ) => {
|
|
// Write mock observations to realm
|
|
await global.realm.write( () => {
|
|
global.realm.create( "User", mockUser );
|
|
} );
|
|
} );
|
|
|
|
it( "should return current user", () => {
|
|
const { result } = renderHook( () => useCurrentUser() );
|
|
const user = global.realm.objects( "User" ).filtered( "signedIn == true" )[0];
|
|
expect( user.login ).toEqual( result.current.login );
|
|
} );
|
|
} );
|