30 lines
920 B
TypeScript
30 lines
920 B
TypeScript
import { vi } from "vitest";
|
|
import type { AuthSecp256k1 } from "../../source/auth/auth";
|
|
import type { RouteDefinition, RouteModule } from "../../source/routes/types";
|
|
|
|
/**
|
|
* Convert an array of route definitions to a route module by returning an object with a getRoutes method that returns the routes.
|
|
* @param routes - The route definitions to convert.
|
|
* @returns A route module.
|
|
*/
|
|
export const toRoutes = (routes: RouteDefinition[]): RouteModule => {
|
|
return {
|
|
getRoutes: async () => routes,
|
|
};
|
|
};
|
|
|
|
|
|
export const mockAuth = {
|
|
verifySignature: vi.fn().mockResolvedValue(true),
|
|
verifyUniqueRequest: vi.fn().mockResolvedValue(true),
|
|
assertTimestampFreshness: vi.fn().mockResolvedValue(true),
|
|
} as unknown as AuthSecp256k1;
|
|
|
|
/**
|
|
* Create a mock of the AuthSecp256k1 service
|
|
* @returns A mock of the AuthSecp256k1 service
|
|
*/
|
|
export const createMockAuth = (): AuthSecp256k1 => {
|
|
return mockAuth;
|
|
};
|