@slashid/react-primitives
Version:
Primitive components for the /id React SDK
51 lines • 2.17 kB
TypeScript
import { FactorMethod, OrganizationDetails, User, PersonHandleType as Handle } from "@slashid/slashid";
import { Handler, PublicReadEvents, SlashID, SlashIDOptions } from "@slashid/slashid";
export declare const TEST_ORG_ID = "ad5399ea-4e88-b04a-16ca-82958c955740";
export declare const TEST_PERSON_ID = "pid:01e43f2419fe994879a64564cd76ab30a8d2ea95e89987c8185cef5ab8f8adf8de643a289c:2";
type Authentication = {
factor: FactorMethod;
handle: Handle;
timestamp: string;
};
type CreateTestUserOptions = {
authMethods?: FactorMethod[];
oid?: string;
authentications?: Authentication[];
token?: string;
};
/**
* Creates new User instance.
* NOTE: This function DOES NOT use or generate a valid token, only one that is easily decoded
* for the purpose of testing the SDK. To be used in the tests ONLY.
*
* @param options CreateTestUserOptions
* @returns User
*/
export declare function createTestUser({ authMethods, oid, authentications, token, }?: CreateTestUserOptions): User;
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;
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;
}
export {};
//# sourceMappingURL=test-utils.d.ts.map