UNPKG

@slashid/react

Version:

React SDK for the /id platform

65 lines 2.9 kB
import { AnonymousUser, FactorMethod, OrganizationDetails, User } from "@slashid/slashid"; import { Handle } from "../domain/types"; import { Handler, PublicReadEvents, SlashID, SlashIDOptions } from "@slashid/slashid"; export declare const inputEmail: (value: string, inputPlaceholder?: string) => void; export declare const inputUsername: (value: string, inputPlaceholder?: string) => void; export declare const inputPhone: (value: string, inputPlaceholder?: string) => void; export declare const TEST_ORG_ID = "ad5399ea-4e88-b04a-16ca-82958c955740"; export declare const TEST_PERSON_ID = "pid:01e43f2419fe994879a64564cd76ab30a8d2ea95e89987c8185cef5ab8f8adf8de643a289c:2"; export declare const testToken: string; type Authentication = { method: FactorMethod; handle: Handle; timestamp: string; }; type CreateTestUserOptions = { authMethods?: FactorMethod[]; oid?: string; authentications?: Authentication[]; token?: string; anonymous?: boolean; sid?: SlashID; }; export declare const createTestUser: (options?: Omit<CreateTestUserOptions, "anonymous">) => User; export declare const createAnonymousTestUser: ({ oid, }?: Pick<CreateTestUserOptions, "oid">) => AnonymousUser; export declare const createTestOrganization: () => OrganizationDetails; export declare const createTestPerson: () => { active: boolean; person_id: string; region: string; }; /** * Radix UI depends Element.onhasPointerCapture, the DOM implementation * in our testing setup has not implemented this. * * https://github.com/testing-library/user-event/discussions/1087 */ export declare const polyfillPointerEvent: () => void; /** * This class is a wrapper on top of the SlashID instance, with mocked * pubsub mechanism. This allows us to test all subscription-related logic * with ease, without the need of accessing private SlashID emitter property. */ export declare class MockSlashID extends SlashID { private _observers; private get observers(); constructor(opts?: SlashIDOptions); subscribe<Key extends keyof PublicReadEvents>(type: Key, handler: Handler<PublicReadEvents[Key]>): void; unsubscribe<Key extends keyof PublicReadEvents>(type: Key, handler: Handler<PublicReadEvents[Key]>): void; mockPublish<Key extends keyof PublicReadEvents>(type: Key, payload: PublicReadEvents[Key]): void; } type Resolver<T> = (value: T | PromiseLike<T>) => void; type Rejecter = (reason?: unknown) => void; /** * A Promise that can be resolved or rejected from the outside. * Useful in tests when you want to wait for a condition to be met. */ export default class Deferred<T> extends Promise<T> { private readonly resolver; private readonly rejecter; constructor(executor?: (resolve: Resolver<T>, reject: Rejecter) => void); resolve(value: T): void; reject(reason?: unknown): void; } export {}; //# sourceMappingURL=test-utils.d.ts.map