diff --git a/packages/realm-react/src/__tests__/mocks.ts b/packages/realm-react/src/__tests__/mocks.ts index be6d08a72a..975630b192 100644 --- a/packages/realm-react/src/__tests__/mocks.ts +++ b/packages/realm-react/src/__tests__/mocks.ts @@ -18,8 +18,7 @@ import { act } from "@testing-library/react-native"; import { EstimateProgressNotificationCallback, ProgressRealmPromise, Realm } from "realm"; -import { sleep } from "../helpers"; -import { SyncSession } from "../../../realm/dist/public-types/internal"; +import { sleep } from "./helpers"; /** * Mocks {@link Realm.ProgressRealmPromise} with a custom @@ -145,7 +144,7 @@ export function mockRealmOpen( } /** Mocks a {@link Realm} with a custom syncSession and returns it. */ -export function mockSyncedRealm({ syncSession }: { syncSession: Partial }) { +export function mockSyncedRealm({ syncSession }: { syncSession: Partial }) { const mockedSyncedRealm = new Realm(); //@ts-expect-error The mock currently supports supplying a subset of methods diff --git a/packages/realm-react/src/__tests__/useProgress.test.tsx b/packages/realm-react/src/__tests__/useProgress.test.tsx index 4d0390b757..e32e45b1b8 100644 --- a/packages/realm-react/src/__tests__/useProgress.test.tsx +++ b/packages/realm-react/src/__tests__/useProgress.test.tsx @@ -72,14 +72,12 @@ describe("useProgress", () => { jest.restoreAllMocks(); }); - ( - [ - [ProgressMode.ReportIndefinitely, ProgressDirection.Download], - [ProgressMode.ReportIndefinitely, ProgressDirection.Upload], - [ProgressMode.ForCurrentlyOutstandingWork, ProgressDirection.Download], - [ProgressMode.ForCurrentlyOutstandingWork, ProgressDirection.Upload], - ] as [ProgressMode, ProgressDirection][] - ).forEach(async ([mode, direction]) => { + for (const [mode, direction] of [ + [ProgressMode.ReportIndefinitely, ProgressDirection.Download], + [ProgressMode.ReportIndefinitely, ProgressDirection.Upload], + [ProgressMode.ForCurrentlyOutstandingWork, ProgressDirection.Download], + [ProgressMode.ForCurrentlyOutstandingWork, ProgressDirection.Upload], + ] as const) { it(`should provide correct progress with ${mode} and ${direction}`, async () => { const realm = mockSyncedRealmWithProgress(); @@ -103,7 +101,7 @@ describe("useProgress", () => { expect(renderedProgressValues).toStrictEqual([null, ...expectedProgress[mode][direction]]); }); - }); + } it("should handle multiple useProgress hooks with different options", async () => { const realm = mockSyncedRealmWithProgress(); diff --git a/packages/realm-react/src/helpers.ts b/packages/realm-react/src/helpers.ts index 8158443349..ed6c2d8d24 100644 --- a/packages/realm-react/src/helpers.ts +++ b/packages/realm-react/src/helpers.ts @@ -58,12 +58,3 @@ export type RestrictivePick = Pick & { [RestrictedKe export function isClassModelConstructor(value: unknown): value is RealmClassType { return Object.getPrototypeOf(value) === Realm.Object; } - -/** - * Adapted from integration-tests - * @param ms For how long should the promise be pending? - * @returns A promise that returns after `ms` milliseconds. - */ -export function sleep(ms = 1000): Promise { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/packages/realm/src/indirect.ts b/packages/realm/src/indirect.ts index c888734244..fbb14b768d 100644 --- a/packages/realm/src/indirect.ts +++ b/packages/realm/src/indirect.ts @@ -47,9 +47,14 @@ type Indirects = { */ export const indirect = {} as Indirects; +const IGNORED_PROPS = new Set([ + // See https://github.com/realm/realm-js/issues/6522 + "$$typeof", +]); + const THROW_ON_ACCESS_HANDLER: ProxyHandler = { get(_target, prop) { - if (typeof prop === "string") { + if (typeof prop === "string" && !IGNORED_PROPS.has(prop)) { throw new AccessError(prop); } },