mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-20 13:38:42 -04:00
* 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
25 lines
666 B
JavaScript
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 );
|
|
} );
|
|
} );
|