Files
iNaturalistReactNative/tests/integration/sharedHooks/useCurrentUser.test.js
Amanda Bullington 1a27ef68cb Upgrade to Realm 12 (#925)
* Update to realm 12

* Remove unused mocks to fix some tests

* Fix test by unmocking ObsEditProvider

* Fix more tests by removing mocks/changing when tests write to realm

* Remove mocks on ObsEdit component test and fix accessibility labels

* Fix hooks tests with realm

* Set test path for realm; finish fixing tests

* Small tweak

* Upgrade realm/react library

* Migrate schema
2023-11-22 13:01:59 -08:00

25 lines
666 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" )[0];
expect( user.login ).toEqual( result.current.login );
} );
} );