Files
iNaturalistReactNative/tests/integration/sharedHooks/useCurrentUser.test.js
Amanda Bullington 808cbee452 Replace ObsEditProvider with zustand for global state management (#948)
* 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
2023-12-05 14:10:00 -08:00

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 );
} );
} );