@pasosdejesus/m 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain/deployments.d.ts +40 -0
- package/dist/blockchain/deployments.d.ts.map +1 -0
- package/dist/blockchain/deployments.js +64 -0
- package/dist/debug/DebugConsole.d.ts +22 -0
- package/dist/debug/DebugConsole.d.ts.map +1 -0
- package/dist/debug/DebugConsole.js +79 -0
- package/dist/debug/Logger.d.ts +38 -0
- package/dist/debug/Logger.d.ts.map +1 -0
- package/dist/debug/Logger.js +94 -0
- package/dist/debug/index.d.ts +6 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +4 -0
- package/dist/debug/useLogger.d.ts +14 -0
- package/dist/debug/useLogger.d.ts.map +1 -0
- package/dist/debug/useLogger.js +23 -0
- package/dist/debug/utils.d.ts +10 -0
- package/dist/debug/utils.d.ts.map +1 -0
- package/dist/debug/utils.js +53 -0
- package/dist/e2e/assertions.d.ts +5 -0
- package/dist/e2e/assertions.d.ts.map +1 -0
- package/dist/e2e/assertions.js +18 -0
- package/dist/e2e/browser.d.ts +37 -0
- package/dist/e2e/browser.d.ts.map +1 -0
- package/dist/e2e/browser.js +97 -0
- package/dist/e2e/env.d.ts +18 -0
- package/dist/e2e/env.d.ts.map +1 -0
- package/dist/e2e/env.js +57 -0
- package/dist/e2e/index.d.ts +11 -0
- package/dist/e2e/index.d.ts.map +1 -0
- package/dist/e2e/index.js +8 -0
- package/dist/e2e/navigation.d.ts +4 -0
- package/dist/e2e/navigation.d.ts.map +1 -0
- package/dist/e2e/navigation.js +32 -0
- package/dist/e2e/siwe-mock.d.ts +11 -0
- package/dist/e2e/siwe-mock.d.ts.map +1 -0
- package/dist/e2e/siwe-mock.js +112 -0
- package/dist/e2e/siwe.d.ts +15 -0
- package/dist/e2e/siwe.d.ts.map +1 -0
- package/dist/e2e/siwe.js +85 -0
- package/dist/e2e/wallet-mock.d.ts +13 -0
- package/dist/e2e/wallet-mock.d.ts.map +1 -0
- package/dist/e2e/wallet-mock.js +91 -0
- package/dist/i18n/common-cli.d.ts +11 -0
- package/dist/i18n/common-cli.d.ts.map +1 -0
- package/dist/i18n/common-cli.js +22 -0
- package/dist/i18n/createTranslator.d.ts +28 -0
- package/dist/i18n/createTranslator.d.ts.map +1 -0
- package/dist/i18n/createTranslator.js +48 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/locales/cli.d.ts +3 -0
- package/dist/i18n/locales/cli.d.ts.map +1 -0
- package/dist/i18n/locales/cli.js +180 -0
- package/dist/i18n/types.d.ts +3 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +10 -0
- package/dist/m.d.ts +2 -0
- package/dist/m.d.ts.map +1 -0
- package/dist/m.js +334 -0
- package/dist/plugin.d.ts +10 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +7 -0
- package/dist/shadcn_components/cn.d.ts +13 -0
- package/dist/shadcn_components/cn.d.ts.map +1 -0
- package/dist/shadcn_components/cn.js +15 -0
- package/dist/shadcn_components/ui/accordion.d.ts +8 -0
- package/dist/shadcn_components/ui/accordion.d.ts.map +1 -0
- package/dist/shadcn_components/ui/accordion.js +14 -0
- package/dist/shadcn_components/ui/alert-dialog.d.ts +21 -0
- package/dist/shadcn_components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/shadcn_components/ui/alert-dialog.js +27 -0
- package/dist/shadcn_components/ui/alert.d.ts +9 -0
- package/dist/shadcn_components/ui/alert.d.ts.map +1 -0
- package/dist/shadcn_components/ui/alert.js +22 -0
- package/dist/shadcn_components/ui/avatar.d.ts +7 -0
- package/dist/shadcn_components/ui/avatar.d.ts.map +1 -0
- package/dist/shadcn_components/ui/avatar.js +12 -0
- package/dist/shadcn_components/ui/badge.d.ts +10 -0
- package/dist/shadcn_components/ui/badge.d.ts.map +1 -0
- package/dist/shadcn_components/ui/badge.js +22 -0
- package/dist/shadcn_components/ui/button.d.ts +11 -0
- package/dist/shadcn_components/ui/button.d.ts.map +1 -0
- package/dist/shadcn_components/ui/button.js +31 -0
- package/dist/shadcn_components/ui/card.d.ts +10 -0
- package/dist/shadcn_components/ui/card.d.ts.map +1 -0
- package/dist/shadcn_components/ui/card.js +24 -0
- package/dist/shadcn_components/ui/checkbox.d.ts +5 -0
- package/dist/shadcn_components/ui/checkbox.d.ts.map +1 -0
- package/dist/shadcn_components/ui/checkbox.js +9 -0
- package/dist/shadcn_components/ui/dialog.d.ts +20 -0
- package/dist/shadcn_components/ui/dialog.d.ts.map +1 -0
- package/dist/shadcn_components/ui/dialog.js +23 -0
- package/dist/shadcn_components/ui/dropdown-menu.d.ts +28 -0
- package/dist/shadcn_components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/shadcn_components/ui/dropdown-menu.js +36 -0
- package/dist/shadcn_components/ui/form.d.ts +24 -0
- package/dist/shadcn_components/ui/form.d.ts.map +1 -0
- package/dist/shadcn_components/ui/form.js +63 -0
- package/dist/shadcn_components/ui/input.d.ts +4 -0
- package/dist/shadcn_components/ui/input.d.ts.map +1 -0
- package/dist/shadcn_components/ui/input.js +6 -0
- package/dist/shadcn_components/ui/label.d.ts +6 -0
- package/dist/shadcn_components/ui/label.d.ts.map +1 -0
- package/dist/shadcn_components/ui/label.js +10 -0
- package/dist/shadcn_components/ui/menubar.d.ts +29 -0
- package/dist/shadcn_components/ui/menubar.d.ts.map +1 -0
- package/dist/shadcn_components/ui/menubar.js +46 -0
- package/dist/shadcn_components/ui/popover.d.ts +7 -0
- package/dist/shadcn_components/ui/popover.d.ts.map +1 -0
- package/dist/shadcn_components/ui/popover.js +10 -0
- package/dist/shadcn_components/ui/progress.d.ts +5 -0
- package/dist/shadcn_components/ui/progress.d.ts.map +1 -0
- package/dist/shadcn_components/ui/progress.js +8 -0
- package/dist/shadcn_components/ui/radio-group.d.ts +6 -0
- package/dist/shadcn_components/ui/radio-group.d.ts.map +1 -0
- package/dist/shadcn_components/ui/radio-group.js +15 -0
- package/dist/shadcn_components/ui/scroll-area.d.ts +6 -0
- package/dist/shadcn_components/ui/scroll-area.d.ts.map +1 -0
- package/dist/shadcn_components/ui/scroll-area.js +12 -0
- package/dist/shadcn_components/ui/select.d.ts +14 -0
- package/dist/shadcn_components/ui/select.d.ts.map +1 -0
- package/dist/shadcn_components/ui/select.js +27 -0
- package/dist/shadcn_components/ui/separator.d.ts +5 -0
- package/dist/shadcn_components/ui/separator.d.ts.map +1 -0
- package/dist/shadcn_components/ui/separator.js +8 -0
- package/dist/shadcn_components/ui/sheet.d.ts +26 -0
- package/dist/shadcn_components/ui/sheet.d.ts.map +1 -0
- package/dist/shadcn_components/ui/sheet.js +37 -0
- package/dist/shadcn_components/ui/skeleton.d.ts +3 -0
- package/dist/shadcn_components/ui/skeleton.d.ts.map +1 -0
- package/dist/shadcn_components/ui/skeleton.js +6 -0
- package/dist/shadcn_components/ui/slider.d.ts +5 -0
- package/dist/shadcn_components/ui/slider.d.ts.map +1 -0
- package/dist/shadcn_components/ui/slider.js +8 -0
- package/dist/shadcn_components/ui/switch.d.ts +5 -0
- package/dist/shadcn_components/ui/switch.d.ts.map +1 -0
- package/dist/shadcn_components/ui/switch.js +8 -0
- package/dist/shadcn_components/ui/table.d.ts +11 -0
- package/dist/shadcn_components/ui/table.d.ts.map +1 -0
- package/dist/shadcn_components/ui/table.js +20 -0
- package/dist/shadcn_components/ui/tabs.d.ts +8 -0
- package/dist/shadcn_components/ui/tabs.d.ts.map +1 -0
- package/dist/shadcn_components/ui/tabs.js +13 -0
- package/dist/shadcn_components/ui/textarea.d.ts +4 -0
- package/dist/shadcn_components/ui/textarea.d.ts.map +1 -0
- package/dist/shadcn_components/ui/textarea.js +8 -0
- package/dist/shadcn_components/ui/toast.d.ts +16 -0
- package/dist/shadcn_components/ui/toast.d.ts.map +1 -0
- package/dist/shadcn_components/ui/toast.js +34 -0
- package/dist/shadcn_components/ui/toaster.d.ts +2 -0
- package/dist/shadcn_components/ui/toaster.d.ts.map +1 -0
- package/dist/shadcn_components/ui/toaster.js +10 -0
- package/dist/shadcn_components/ui/tooltip.d.ts +8 -0
- package/dist/shadcn_components/ui/tooltip.d.ts.map +1 -0
- package/dist/shadcn_components/ui/tooltip.js +11 -0
- package/dist/shadcn_components/ui/use-toast.d.ts +45 -0
- package/dist/shadcn_components/ui/use-toast.d.ts.map +1 -0
- package/dist/shadcn_components/ui/use-toast.js +126 -0
- package/dist/tasks/context.d.ts +13 -0
- package/dist/tasks/context.d.ts.map +1 -0
- package/dist/tasks/context.js +310 -0
- package/dist/tasks/create.d.ts +2 -0
- package/dist/tasks/create.d.ts.map +1 -0
- package/dist/tasks/create.js +91 -0
- package/dist/tasks/db.d.ts +19 -0
- package/dist/tasks/db.d.ts.map +1 -0
- package/dist/tasks/db.js +791 -0
- package/dist/tasks/e2e.d.ts +2 -0
- package/dist/tasks/e2e.d.ts.map +1 -0
- package/dist/tasks/e2e.js +124 -0
- package/dist/tasks/edit.d.ts +7 -0
- package/dist/tasks/edit.d.ts.map +1 -0
- package/dist/tasks/edit.js +471 -0
- package/dist/tasks/engine.d.ts +2 -0
- package/dist/tasks/engine.d.ts.map +1 -0
- package/dist/tasks/engine.js +149 -0
- package/dist/tasks/env-diff.d.ts +2 -0
- package/dist/tasks/env-diff.d.ts.map +1 -0
- package/dist/tasks/env-diff.js +140 -0
- package/dist/tasks/fuzzy.d.ts +9 -0
- package/dist/tasks/fuzzy.d.ts.map +1 -0
- package/dist/tasks/fuzzy.js +153 -0
- package/dist/tasks/glob.d.ts +5 -0
- package/dist/tasks/glob.d.ts.map +1 -0
- package/dist/tasks/glob.js +57 -0
- package/dist/tasks/grep.d.ts +9 -0
- package/dist/tasks/grep.d.ts.map +1 -0
- package/dist/tasks/grep.js +93 -0
- package/dist/tasks/readfile.d.ts +2 -0
- package/dist/tasks/readfile.d.ts.map +1 -0
- package/dist/tasks/readfile.js +177 -0
- package/dist/tasks/update.d.ts +5 -0
- package/dist/tasks/update.d.ts.map +1 -0
- package/dist/tasks/update.js +200 -0
- package/dist/tasks/util.d.ts +12 -0
- package/dist/tasks/util.d.ts.map +1 -0
- package/dist/tasks/util.js +42 -0
- package/dist/tasks/wallet.d.ts +2 -0
- package/dist/tasks/wallet.d.ts.map +1 -0
- package/dist/tasks/wallet.js +697 -0
- package/dist/tasks/writefile.d.ts +2 -0
- package/dist/tasks/writefile.d.ts.map +1 -0
- package/dist/tasks/writefile.js +66 -0
- package/dist/templates/AGENTS.md.hbs +81 -0
- package/dist/templates/ARCHITECTURE.md.hbs +146 -0
- package/dist/templates/CONTRIBUTING.md.hbs +83 -0
- package/dist/templates/LICENCIA.md +21 -0
- package/dist/templates/LICENSE.md +15 -0
- package/dist/templates/Makefile +16 -0
- package/dist/templates/README.md.hbs +111 -0
- package/dist/templates/apps/.env.example.hbs +75 -0
- package/dist/templates/apps/hardhat/.prettierrc +16 -0
- package/dist/templates/apps/hardhat/MOCK_USDT_README.md +20 -0
- package/dist/templates/apps/hardhat/Makefile +13 -0
- package/dist/templates/apps/hardhat/README.md +129 -0
- package/dist/templates/apps/hardhat/bin/MusdtVerification +4 -0
- package/dist/templates/apps/hardhat/bin/approveDepositOwner +7 -0
- package/dist/templates/apps/hardhat/bin/contractVerification +9 -0
- package/dist/templates/apps/hardhat/bin/deployMockUSDT +7 -0
- package/dist/templates/apps/hardhat/bin/prepadJ.sh +14 -0
- package/dist/templates/apps/hardhat/bin/verifyMockUSDT +7 -0
- package/dist/templates/apps/hardhat/contracts/MockUSDT.sol +47 -0
- package/dist/templates/apps/hardhat/hardhat.config.ts +102 -0
- package/dist/templates/apps/hardhat/package.json +55 -0
- package/dist/templates/apps/hardhat/scripts/approveDepositOwner.ts +22 -0
- package/dist/templates/apps/hardhat/scripts/deployMockUSDT.ts +49 -0
- package/dist/templates/apps/hardhat/scripts/verifyDeployment.ts +93 -0
- package/dist/templates/apps/hardhat/scripts/verifyMockUSDT.ts +52 -0
- package/dist/templates/apps/hardhat/sync-abis.mjs +58 -0
- package/dist/templates/apps/hardhat/test/MockUSDT.test.ts +40 -0
- package/dist/templates/apps/hardhat/tsconfig.json +27 -0
- package/dist/templates/apps/nextjs/.config/kysely.config.ts +36 -0
- package/dist/templates/apps/nextjs/Makefile +24 -0
- package/dist/templates/apps/nextjs/README.md.hbs +76 -0
- package/dist/templates/apps/nextjs/abis/IERC20.json +74 -0
- package/dist/templates/apps/nextjs/abis/MockUSDT.json +242 -0
- package/dist/templates/apps/nextjs/abis/ReentrancyGuard.json +1 -0
- package/dist/templates/apps/nextjs/app/globals.css +3 -0
- package/dist/templates/apps/nextjs/app/layout.tsx.hbs +26 -0
- package/dist/templates/apps/nextjs/app/page.tsx.hbs +225 -0
- package/dist/templates/apps/nextjs/app/testui/page.tsx +371 -0
- package/dist/templates/apps/nextjs/bin/m +8 -0
- package/dist/templates/apps/nextjs/components.json +21 -0
- package/dist/templates/apps/nextjs/next-env.d.ts +5 -0
- package/dist/templates/apps/nextjs/next.config.ts +10 -0
- package/dist/templates/apps/nextjs/package.json.hbs +48 -0
- package/dist/templates/apps/nextjs/pnpm-workspace.yaml +13 -0
- package/dist/templates/apps/nextjs/postcss.config.mjs +6 -0
- package/dist/templates/apps/nextjs/tailwind.config.js +11 -0
- package/dist/templates/apps/nextjs/tests/helpers.ts +31 -0
- package/dist/templates/apps/nextjs/tests/index.test.ts +7 -0
- package/dist/templates/apps/nextjs/tests/setup-env.ts.hbs +8 -0
- package/dist/templates/apps/nextjs/tests/test-utils.example.test.ts +168 -0
- package/dist/templates/apps/nextjs/tsconfig.json +44 -0
- package/dist/templates/apps/nextjs/tsconfig.test.json +38 -0
- package/dist/templates/apps/nextjs/vitest.config.ts +13 -0
- package/dist/test-utils/fs-mocks.d.ts +32 -0
- package/dist/test-utils/fs-mocks.d.ts.map +1 -0
- package/dist/test-utils/fs-mocks.js +63 -0
- package/dist/test-utils/i18n-mock.d.ts +21 -0
- package/dist/test-utils/i18n-mock.d.ts.map +1 -0
- package/dist/test-utils/i18n-mock.js +29 -0
- package/dist/test-utils/index.d.ts +12 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +11 -0
- package/dist/test-utils/kysely-mocks.d.ts +298 -0
- package/dist/test-utils/kysely-mocks.d.ts.map +1 -0
- package/dist/test-utils/kysely-mocks.js +173 -0
- package/dist/test-utils/radix-mocks.d.ts +134 -0
- package/dist/test-utils/radix-mocks.d.ts.map +1 -0
- package/dist/test-utils/radix-mocks.js +175 -0
- package/dist/test-utils/rainbowkit-mocks.d.ts +80 -0
- package/dist/test-utils/rainbowkit-mocks.d.ts.map +1 -0
- package/dist/test-utils/rainbowkit-mocks.js +247 -0
- package/dist/test-utils/viem-mocks.d.ts +86 -0
- package/dist/test-utils/viem-mocks.d.ts.map +1 -0
- package/dist/test-utils/viem-mocks.js +54 -0
- package/dist/util/cli-parser.d.ts +20 -0
- package/dist/util/cli-parser.d.ts.map +1 -0
- package/dist/util/cli-parser.js +38 -0
- package/dist/util/colors.d.ts +5 -0
- package/dist/util/colors.d.ts.map +1 -0
- package/dist/util/colors.js +5 -0
- package/dist/util/locale.d.ts +3 -0
- package/dist/util/locale.d.ts.map +1 -0
- package/dist/util/locale.js +10 -0
- package/dist/wba/client.d.ts +19 -0
- package/dist/wba/client.d.ts.map +1 -0
- package/dist/wba/client.js +31 -0
- package/dist/wba/index.d.ts +4 -0
- package/dist/wba/index.d.ts.map +1 -0
- package/dist/wba/index.js +2 -0
- package/dist/wba/routes/event.d.ts +32 -0
- package/dist/wba/routes/event.d.ts.map +1 -0
- package/dist/wba/routes/event.js +42 -0
- package/dist/wba/routes/index.d.ts +3 -0
- package/dist/wba/routes/index.d.ts.map +1 -0
- package/dist/wba/routes/index.js +2 -0
- package/dist/wba/routes/summary.d.ts +44 -0
- package/dist/wba/routes/summary.d.ts.map +1 -0
- package/dist/wba/routes/summary.js +146 -0
- package/dist/wba/server.d.ts +18 -0
- package/dist/wba/server.d.ts.map +1 -0
- package/dist/wba/server.js +29 -0
- package/dist/wba/types.d.ts +68 -0
- package/dist/wba/types.d.ts.map +1 -0
- package/dist/wba/types.js +6 -0
- package/package.json +223 -0
- package/src/blockchain/README.md +80 -0
- package/src/debug/README.md +94 -0
- package/src/e2e/README.md +105 -0
- package/src/i18n/README.md +143 -0
- package/src/shadcn_components/README.md +125 -0
- package/src/tasks/README.md +69 -0
- package/src/test-utils/README.md +638 -0
- package/src/util/README.md +18 -0
- package/src/wba/README.md +175 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Radix UI mocks for testing
|
|
4
|
+
*
|
|
5
|
+
* "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { vi } from 'vitest';
|
|
9
|
+
// Mock ResizeObserver globally
|
|
10
|
+
if (typeof global !== 'undefined' && !global.ResizeObserver) {
|
|
11
|
+
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
12
|
+
observe: vi.fn(),
|
|
13
|
+
unobserve: vi.fn(),
|
|
14
|
+
disconnect: vi.fn(),
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Mock for @radix-ui/react-portal
|
|
19
|
+
* Renders children directly instead of in a portal
|
|
20
|
+
*/
|
|
21
|
+
export const portalMock = {
|
|
22
|
+
Portal: ({ children }) => children,
|
|
23
|
+
Root: ({ children }) => children,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Mock for @radix-ui/react-menubar
|
|
27
|
+
* Provides simplified components that render without complex context
|
|
28
|
+
*/
|
|
29
|
+
export const menubarMock = {
|
|
30
|
+
Root: React.forwardRef(function Root({ className, ...props }, ref) {
|
|
31
|
+
return React.createElement('div', { ref, 'data-testid': 'menubar-root', className, ...props });
|
|
32
|
+
}),
|
|
33
|
+
Menu: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-menu", className: className, ...props }))),
|
|
34
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "menubar-trigger", className: className, ...props, children: props.children }))),
|
|
35
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-content", className: className, ...props }))),
|
|
36
|
+
Item: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "menubar-item", className: className, ...props, children: props.children }))),
|
|
37
|
+
Separator: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-separator", className: className, ...props }))),
|
|
38
|
+
Label: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-label", className: className, ...props, children: props.children }))),
|
|
39
|
+
CheckboxItem: React.forwardRef(({ className, checked, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "menubar-checkbox-item", "data-checked": checked, className: className, ...props, children: props.children }))),
|
|
40
|
+
RadioGroup: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-radio-group", className: className, ...props }))),
|
|
41
|
+
RadioItem: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "menubar-radio-item", className: className, ...props, children: props.children }))),
|
|
42
|
+
Group: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-group", className: className, ...props }))),
|
|
43
|
+
ItemIndicator: React.forwardRef(({ className, ...props }, ref) => (_jsx("span", { ref: ref, "data-testid": "menubar-item-indicator", className: className, ...props }))),
|
|
44
|
+
Sub: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-sub", className: className, ...props }))),
|
|
45
|
+
SubTrigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "menubar-sub-trigger", className: className, ...props, children: props.children }))),
|
|
46
|
+
SubContent: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "menubar-sub-content", className: className, ...props }))),
|
|
47
|
+
Shortcut: ({ className, ...props }) => (_jsx("span", { "data-testid": "menubar-shortcut", className: className, ...props })),
|
|
48
|
+
Portal: portalMock.Portal,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Mock for @radix-ui/react-popover
|
|
52
|
+
*/
|
|
53
|
+
export const popoverMock = {
|
|
54
|
+
Root: React.forwardRef(({ className, defaultOpen = false, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "popover-root", "data-state": defaultOpen ? 'open' : 'closed', className: className, ...props }))),
|
|
55
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "popover-trigger", className: className, ...props, children: props.children }))),
|
|
56
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "popover-content", className: className, ...props }))),
|
|
57
|
+
Portal: portalMock.Portal,
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Mock for @radix-ui/react-dropdown-menu
|
|
61
|
+
*/
|
|
62
|
+
export const dropdownMenuMock = {
|
|
63
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-root", className: className, ...props }))),
|
|
64
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dropdown-menu-trigger", className: className, ...props, children: props.children }))),
|
|
65
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-content", className: className, ...props }))),
|
|
66
|
+
Item: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dropdown-menu-item", className: className, ...props, children: props.children }))),
|
|
67
|
+
Separator: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-separator", className: className, ...props }))),
|
|
68
|
+
Label: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-label", className: className, ...props, children: props.children }))),
|
|
69
|
+
CheckboxItem: React.forwardRef(({ className, checked, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dropdown-menu-checkbox-item", "data-checked": checked, className: className, ...props, children: props.children }))),
|
|
70
|
+
RadioGroup: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-radio-group", className: className, ...props }))),
|
|
71
|
+
RadioItem: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dropdown-menu-radio-item", className: className, ...props, children: props.children }))),
|
|
72
|
+
Sub: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-sub", className: className, ...props }))),
|
|
73
|
+
SubTrigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dropdown-menu-sub-trigger", className: className, ...props, children: props.children }))),
|
|
74
|
+
SubContent: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dropdown-menu-sub-content", className: className, ...props }))),
|
|
75
|
+
Shortcut: ({ className, ...props }) => (_jsx("span", { "data-testid": "dropdown-menu-shortcut", className: className, ...props })),
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Mock for @radix-ui/react-dialog (used by sheet, alert-dialog)
|
|
79
|
+
*/
|
|
80
|
+
export const dialogMock = {
|
|
81
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dialog-root", className: className, ...props }))),
|
|
82
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dialog-trigger", className: className, ...props, children: props.children }))),
|
|
83
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dialog-content", className: className, ...props }))),
|
|
84
|
+
Overlay: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dialog-overlay", className: className, ...props }))),
|
|
85
|
+
Title: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dialog-title", className: className, ...props, children: props.children }))),
|
|
86
|
+
Description: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "dialog-description", className: className, ...props, children: props.children }))),
|
|
87
|
+
Close: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "dialog-close", className: className, ...props, children: props.children }))),
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Mock for @radix-ui/react-toast
|
|
91
|
+
*/
|
|
92
|
+
export const toastMock = {
|
|
93
|
+
Provider: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "toast-provider", className: className, ...props }))),
|
|
94
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "toast-root", className: className, ...props }))),
|
|
95
|
+
Title: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "toast-title", className: className, ...props, children: props.children }))),
|
|
96
|
+
Description: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "toast-description", className: className, ...props, children: props.children }))),
|
|
97
|
+
Action: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "toast-action", className: className, ...props, children: props.children }))),
|
|
98
|
+
Close: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "toast-close", className: className, ...props, children: props.children }))),
|
|
99
|
+
Viewport: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "toast-viewport", className: className, ...props }))),
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Mock for @radix-ui/react-tooltip
|
|
103
|
+
*/
|
|
104
|
+
export const tooltipMock = {
|
|
105
|
+
Provider: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tooltip-provider", className: className, ...props }))),
|
|
106
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tooltip-root", className: className, ...props }))),
|
|
107
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "tooltip-trigger", className: className, ...props, children: props.children }))),
|
|
108
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tooltip-content", className: className, ...props }))),
|
|
109
|
+
Arrow: ({ className, ...props }) => (_jsx("div", { "data-testid": "tooltip-arrow", className: className, ...props })),
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Common Radix UI component mocks
|
|
113
|
+
*/
|
|
114
|
+
export const commonRadixMocks = {
|
|
115
|
+
Slot: ({ children, ...props }) => React.cloneElement(React.Children.only(children), props),
|
|
116
|
+
Label: React.forwardRef(({ className, ...props }, ref) => (_jsx("label", { ref: ref, "data-testid": "radix-label", className: className, ...props }))),
|
|
117
|
+
Separator: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "radix-separator", className: className, ...props }))),
|
|
118
|
+
};
|
|
119
|
+
export const scrollAreaMock = {
|
|
120
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-root", className: className, ...props }))),
|
|
121
|
+
Viewport: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-viewport", className: className, ...props }))),
|
|
122
|
+
Scrollbar: React.forwardRef(({ className, orientation = 'vertical', ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-scrollbar", "data-orientation": orientation, className: className, ...props }))),
|
|
123
|
+
Thumb: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-thumb", className: className, ...props }))),
|
|
124
|
+
ScrollAreaScrollbar: React.forwardRef(({ className, orientation = 'vertical', ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-scrollbar", "data-orientation": orientation, className: className, ...props }))),
|
|
125
|
+
Corner: ({ className, ...props }) => (_jsx("div", { "data-testid": "scroll-area-corner", className: className, ...props })),
|
|
126
|
+
ScrollAreaThumb: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-thumb", className: className, ...props }))),
|
|
127
|
+
ScrollAreaViewport: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-viewport", className: className, ...props }))),
|
|
128
|
+
ScrollAreaCorner: ({ className, ...props }) => (_jsx("div", { "data-testid": "scroll-area-corner", className: className, ...props })),
|
|
129
|
+
ScrollAreaRoot: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-root", className: className, ...props }))),
|
|
130
|
+
};
|
|
131
|
+
export const tabsMock = {
|
|
132
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tabs-root", className: className, ...props }))),
|
|
133
|
+
List: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tabs-list", className: className, ...props }))),
|
|
134
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "tabs-trigger", className: className, ...props, children: props.children }))),
|
|
135
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tabs-content", className: className, ...props }))),
|
|
136
|
+
};
|
|
137
|
+
// Radix UI mocks configuration
|
|
138
|
+
export function setupRadixMocks() {
|
|
139
|
+
console.warn('setupRadixMocks called');
|
|
140
|
+
vi.mock('@radix-ui/react-portal', () => portalMock);
|
|
141
|
+
vi.mock('@radix-ui/react-menubar', () => menubarMock);
|
|
142
|
+
vi.mock('@radix-ui/react-popover', () => popoverMock);
|
|
143
|
+
vi.mock('@radix-ui/react-dropdown-menu', () => dropdownMenuMock);
|
|
144
|
+
vi.mock('@radix-ui/react-dialog', () => dialogMock);
|
|
145
|
+
vi.mock('@radix-ui/react-toast', () => toastMock);
|
|
146
|
+
vi.mock('@radix-ui/react-tooltip', () => tooltipMock);
|
|
147
|
+
vi.mock('@radix-ui/react-slot', () => ({ Slot: commonRadixMocks.Slot }));
|
|
148
|
+
vi.mock('@radix-ui/react-label', () => ({ Root: commonRadixMocks.Label }));
|
|
149
|
+
vi.mock('@radix-ui/react-separator', () => ({ Root: commonRadixMocks.Separator }));
|
|
150
|
+
// Additional common Radix UI packages
|
|
151
|
+
vi.mock('@radix-ui/react-accordion', () => ({
|
|
152
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "accordion-root", className: className, ...props }))),
|
|
153
|
+
Item: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "accordion-item", className: className, ...props }))),
|
|
154
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "accordion-trigger", className: className, ...props, children: props.children }))),
|
|
155
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "accordion-content", className: className, ...props }))),
|
|
156
|
+
}));
|
|
157
|
+
vi.mock('@radix-ui/react-scroll-area', () => ({
|
|
158
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-root", className: className, ...props }))),
|
|
159
|
+
Viewport: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-viewport", className: className, ...props }))),
|
|
160
|
+
Scrollbar: React.forwardRef(({ className, orientation = 'vertical', ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-scrollbar", "data-orientation": orientation, className: className, ...props }))),
|
|
161
|
+
Thumb: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-thumb", className: className, ...props }))),
|
|
162
|
+
ScrollAreaScrollbar: React.forwardRef(({ className, orientation = 'vertical', ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-scrollbar", "data-orientation": orientation, className: className, ...props }))),
|
|
163
|
+
Corner: ({ className, ...props }) => (_jsx("div", { "data-testid": "scroll-area-corner", className: className, ...props })),
|
|
164
|
+
ScrollAreaThumb: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-thumb", className: className, ...props }))),
|
|
165
|
+
ScrollAreaViewport: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-viewport", className: className, ...props }))),
|
|
166
|
+
ScrollAreaCorner: ({ className, ...props }) => (_jsx("div", { "data-testid": "scroll-area-corner", className: className, ...props })),
|
|
167
|
+
ScrollAreaRoot: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "scroll-area-root", className: className, ...props }))),
|
|
168
|
+
}));
|
|
169
|
+
vi.mock('@radix-ui/react-tabs', () => ({
|
|
170
|
+
Root: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tabs-root", className: className, ...props }))),
|
|
171
|
+
List: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tabs-list", className: className, ...props }))),
|
|
172
|
+
Trigger: React.forwardRef(({ className, ...props }, ref) => (_jsx("button", { ref: ref, "data-testid": "tabs-trigger", className: className, ...props, children: props.children }))),
|
|
173
|
+
Content: React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-testid": "tabs-content", className: className, ...props }))),
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication mocking utilities for tests
|
|
3
|
+
*
|
|
4
|
+
* "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Mock configurations for authentication
|
|
8
|
+
*/
|
|
9
|
+
export interface AuthMockConfig {
|
|
10
|
+
address?: string;
|
|
11
|
+
isConnected?: boolean;
|
|
12
|
+
sessionData?: any;
|
|
13
|
+
csrfToken?: string;
|
|
14
|
+
siweVerificationSuccess?: boolean;
|
|
15
|
+
/** Chain ID for wallet connection (default: 1) */
|
|
16
|
+
chainId?: number;
|
|
17
|
+
/** Whether to mock axios module (default: true) */
|
|
18
|
+
mockAxios?: boolean;
|
|
19
|
+
/** Axios mock configuration - can provide custom mock implementations */
|
|
20
|
+
axiosMock?: {
|
|
21
|
+
get?: (...args: any[]) => any;
|
|
22
|
+
post?: (...args: any[]) => any;
|
|
23
|
+
put?: (...args: any[]) => any;
|
|
24
|
+
delete?: (...args: any[]) => any;
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
/** Whether to mock wagmi module (default: true) */
|
|
28
|
+
mockWagmi?: boolean;
|
|
29
|
+
/** Whether to mock siwe module (default: true) */
|
|
30
|
+
mockSiwe?: boolean;
|
|
31
|
+
/** Whether to mock next-auth/react module (default: true) */
|
|
32
|
+
mockNextAuth?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates authentication mocks with configurable behavior
|
|
36
|
+
*
|
|
37
|
+
* @param config Configuration for mock behavior
|
|
38
|
+
* @returns Object containing mocked authentication functions and setup helpers
|
|
39
|
+
*/
|
|
40
|
+
export declare function createAuthMocks(config?: AuthMockConfig): {
|
|
41
|
+
mocks: {
|
|
42
|
+
mockSiweMessage: import("vitest").Mock<(...args: any[]) => any>;
|
|
43
|
+
mockGetCsrfToken: import("vitest").Mock<(...args: any[]) => any>;
|
|
44
|
+
mockUseSession: import("vitest").Mock<(...args: any[]) => any>;
|
|
45
|
+
mockUseAccount: import("vitest").Mock<(...args: any[]) => any>;
|
|
46
|
+
mockAxiosGet: import("vitest").Mock<(...args: any[]) => any>;
|
|
47
|
+
mockAxiosPost: import("vitest").Mock<(...args: any[]) => any>;
|
|
48
|
+
mockAxiosPut: import("vitest").Mock<(...args: any[]) => any>;
|
|
49
|
+
mockAxiosDelete: import("vitest").Mock<(...args: any[]) => any>;
|
|
50
|
+
mockAxiosRequest: import("vitest").Mock<(...args: any[]) => any>;
|
|
51
|
+
};
|
|
52
|
+
setupMocks: () => void;
|
|
53
|
+
setupDefaultImplementations: () => void;
|
|
54
|
+
resetMocks: () => void;
|
|
55
|
+
updateConfig: (newConfig: Partial<AuthMockConfig>) => void;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Pre-configured authentication mocks for API route tests
|
|
59
|
+
*/
|
|
60
|
+
export declare const apiAuthMocks: {
|
|
61
|
+
mocks: {
|
|
62
|
+
mockSiweMessage: import("vitest").Mock<(...args: any[]) => any>;
|
|
63
|
+
mockGetCsrfToken: import("vitest").Mock<(...args: any[]) => any>;
|
|
64
|
+
mockUseSession: import("vitest").Mock<(...args: any[]) => any>;
|
|
65
|
+
mockUseAccount: import("vitest").Mock<(...args: any[]) => any>;
|
|
66
|
+
mockAxiosGet: import("vitest").Mock<(...args: any[]) => any>;
|
|
67
|
+
mockAxiosPost: import("vitest").Mock<(...args: any[]) => any>;
|
|
68
|
+
mockAxiosPut: import("vitest").Mock<(...args: any[]) => any>;
|
|
69
|
+
mockAxiosDelete: import("vitest").Mock<(...args: any[]) => any>;
|
|
70
|
+
mockAxiosRequest: import("vitest").Mock<(...args: any[]) => any>;
|
|
71
|
+
};
|
|
72
|
+
setupMocks: () => void;
|
|
73
|
+
setupDefaultImplementations: () => void;
|
|
74
|
+
resetMocks: () => void;
|
|
75
|
+
updateConfig: (newConfig: Partial<AuthMockConfig>) => void;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Pre-configured authentication mocks for hook tests
|
|
79
|
+
*/
|
|
80
|
+
//# sourceMappingURL=rainbowkit-mocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rainbowkit-mocks.d.ts","sourceRoot":"","sources":["../../src/test-utils/rainbowkit-mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,GAAG,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,yEAAyE;IACzE,SAAS,CAAC,EAAE;QACV,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;QAC7B,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;QAC9B,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;QAC7B,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;QAChC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACnB,CAAA;IACD,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,cAAmB;;;;;;;;;;;;;;;8BAmLxB,OAAO,CAAC,cAAc,CAAC;EA4EzD;AAED;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;8BAjFU,OAAO,CAAC,cAAc,CAAC;CAiFb,CAAA;AAE7C;;GAEG"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication mocking utilities for tests
|
|
3
|
+
*
|
|
4
|
+
* "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
|
|
5
|
+
*/
|
|
6
|
+
import { vi } from 'vitest';
|
|
7
|
+
/**
|
|
8
|
+
* Creates authentication mocks with configurable behavior
|
|
9
|
+
*
|
|
10
|
+
* @param config Configuration for mock behavior
|
|
11
|
+
* @returns Object containing mocked authentication functions and setup helpers
|
|
12
|
+
*/
|
|
13
|
+
export function createAuthMocks(config = {}) {
|
|
14
|
+
const { address = '0x1234567890123456789012345678901234567890', isConnected = true, sessionData = { user: { name: 'Test User' } }, csrfToken = 'mock-csrf-token', siweVerificationSuccess = true, chainId = 1, mockAxios = true, axiosMock = {}, mockWagmi = true, mockSiwe = true, mockNextAuth = true, } = config;
|
|
15
|
+
// Capture axiosMock for use in hoisted functions
|
|
16
|
+
const capturedAxiosMock = axiosMock;
|
|
17
|
+
// Hoisted mocks to avoid initialization issues
|
|
18
|
+
const mocks = vi.hoisted(() => {
|
|
19
|
+
const mockSiweMessage = vi.fn();
|
|
20
|
+
const mockGetCsrfToken = vi.fn();
|
|
21
|
+
const mockUseSession = vi.fn();
|
|
22
|
+
const mockUseAccount = vi.fn();
|
|
23
|
+
const mockAxiosGet = vi.fn();
|
|
24
|
+
const mockAxiosPost = vi.fn();
|
|
25
|
+
const mockAxiosPut = vi.fn();
|
|
26
|
+
const mockAxiosDelete = vi.fn();
|
|
27
|
+
const mockAxiosRequest = vi.fn();
|
|
28
|
+
return {
|
|
29
|
+
mockSiweMessage,
|
|
30
|
+
mockGetCsrfToken,
|
|
31
|
+
mockUseSession,
|
|
32
|
+
mockUseAccount,
|
|
33
|
+
mockAxiosGet,
|
|
34
|
+
mockAxiosPost,
|
|
35
|
+
mockAxiosPut,
|
|
36
|
+
mockAxiosDelete,
|
|
37
|
+
mockAxiosRequest,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Setup vi.mock calls for authentication modules
|
|
42
|
+
* Call this in your test file's setup
|
|
43
|
+
*/
|
|
44
|
+
function setupMocks() {
|
|
45
|
+
// Mock siwe (Sign-In With Ethereum) if enabled
|
|
46
|
+
if (mockSiwe) {
|
|
47
|
+
vi.mock('siwe', () => ({
|
|
48
|
+
SiweMessage: mocks.mockSiweMessage,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
// Mock next-auth/react if enabled
|
|
52
|
+
if (mockNextAuth) {
|
|
53
|
+
vi.mock('next-auth/react', () => ({
|
|
54
|
+
useSession: () => mocks.mockUseSession(),
|
|
55
|
+
getCsrfToken: () => mocks.mockGetCsrfToken(),
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
// Mock wagmi if enabled
|
|
59
|
+
if (mockWagmi) {
|
|
60
|
+
vi.mock('wagmi', async () => {
|
|
61
|
+
const actual = await vi.importActual('wagmi');
|
|
62
|
+
return {
|
|
63
|
+
...actual,
|
|
64
|
+
useConfig: () => ({}),
|
|
65
|
+
useAccount: () => mocks.mockUseAccount(),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// Mock axios for API calls if enabled
|
|
70
|
+
if (mockAxios) {
|
|
71
|
+
vi.mock('axios', () => ({
|
|
72
|
+
default: {
|
|
73
|
+
get: (...args) => mocks.mockAxiosGet(...args),
|
|
74
|
+
post: (...args) => mocks.mockAxiosPost(...args),
|
|
75
|
+
put: (...args) => mocks.mockAxiosPut(...args),
|
|
76
|
+
delete: (...args) => mocks.mockAxiosDelete(...args),
|
|
77
|
+
request: (...args) => mocks.mockAxiosRequest(...args),
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set up default mock implementations based on config
|
|
84
|
+
*/
|
|
85
|
+
function setupDefaultImplementations() {
|
|
86
|
+
// SiweMessage mock
|
|
87
|
+
mocks.mockSiweMessage.mockImplementation(() => ({
|
|
88
|
+
address,
|
|
89
|
+
verify: vi.fn().mockResolvedValue({
|
|
90
|
+
success: siweVerificationSuccess,
|
|
91
|
+
data: { nonce: 'mock-nonce', chainId },
|
|
92
|
+
}),
|
|
93
|
+
}));
|
|
94
|
+
// NextAuth mocks
|
|
95
|
+
mocks.mockUseSession.mockReturnValue({
|
|
96
|
+
data: {
|
|
97
|
+
...sessionData,
|
|
98
|
+
address,
|
|
99
|
+
},
|
|
100
|
+
status: 'authenticated',
|
|
101
|
+
expires: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
|
|
102
|
+
});
|
|
103
|
+
mocks.mockGetCsrfToken.mockResolvedValue(csrfToken);
|
|
104
|
+
// Wagmi mock
|
|
105
|
+
mocks.mockUseAccount.mockReturnValue({
|
|
106
|
+
address,
|
|
107
|
+
isConnected,
|
|
108
|
+
chainId,
|
|
109
|
+
});
|
|
110
|
+
// Axios mocks - default success responses for all methods
|
|
111
|
+
// Only set defaults if custom implementation not provided
|
|
112
|
+
if (!capturedAxiosMock.get) {
|
|
113
|
+
mocks.mockAxiosGet.mockResolvedValue({
|
|
114
|
+
data: {},
|
|
115
|
+
status: 200,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
mocks.mockAxiosGet.mockImplementation(capturedAxiosMock.get);
|
|
120
|
+
}
|
|
121
|
+
if (!capturedAxiosMock.post) {
|
|
122
|
+
mocks.mockAxiosPost.mockResolvedValue({
|
|
123
|
+
data: {},
|
|
124
|
+
status: 200,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
mocks.mockAxiosPost.mockImplementation(capturedAxiosMock.post);
|
|
129
|
+
}
|
|
130
|
+
if (!capturedAxiosMock.put) {
|
|
131
|
+
mocks.mockAxiosPut.mockResolvedValue({
|
|
132
|
+
data: {},
|
|
133
|
+
status: 200,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
mocks.mockAxiosPut.mockImplementation(capturedAxiosMock.put);
|
|
138
|
+
}
|
|
139
|
+
if (!capturedAxiosMock.delete) {
|
|
140
|
+
mocks.mockAxiosDelete.mockResolvedValue({
|
|
141
|
+
data: {},
|
|
142
|
+
status: 200,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
mocks.mockAxiosDelete.mockImplementation(capturedAxiosMock.delete);
|
|
147
|
+
}
|
|
148
|
+
if (!capturedAxiosMock.request) {
|
|
149
|
+
mocks.mockAxiosRequest.mockResolvedValue({
|
|
150
|
+
data: {},
|
|
151
|
+
status: 200,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
mocks.mockAxiosRequest.mockImplementation(capturedAxiosMock.request);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Reset all mock implementations
|
|
160
|
+
*/
|
|
161
|
+
function resetMocks() {
|
|
162
|
+
Object.values(mocks).forEach(mock => {
|
|
163
|
+
if (typeof mock.mockReset === 'function') {
|
|
164
|
+
mock.mockReset();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Update mock configurations dynamically
|
|
170
|
+
*/
|
|
171
|
+
function updateConfig(newConfig) {
|
|
172
|
+
if (newConfig.address !== undefined) {
|
|
173
|
+
mocks.mockUseAccount.mockReturnValue({
|
|
174
|
+
address: newConfig.address,
|
|
175
|
+
isConnected: newConfig.isConnected ?? isConnected,
|
|
176
|
+
chainId: newConfig.chainId ?? chainId,
|
|
177
|
+
});
|
|
178
|
+
mocks.mockUseSession.mockReturnValue({
|
|
179
|
+
data: {
|
|
180
|
+
...sessionData,
|
|
181
|
+
address: newConfig.address,
|
|
182
|
+
},
|
|
183
|
+
status: 'authenticated',
|
|
184
|
+
expires: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (newConfig.isConnected !== undefined) {
|
|
188
|
+
mocks.mockUseAccount.mockReturnValue({
|
|
189
|
+
address,
|
|
190
|
+
isConnected: newConfig.isConnected,
|
|
191
|
+
chainId: newConfig.chainId ?? chainId,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (newConfig.sessionData !== undefined) {
|
|
195
|
+
mocks.mockUseSession.mockReturnValue({
|
|
196
|
+
data: {
|
|
197
|
+
...newConfig.sessionData,
|
|
198
|
+
address,
|
|
199
|
+
},
|
|
200
|
+
status: 'authenticated',
|
|
201
|
+
expires: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (newConfig.csrfToken !== undefined) {
|
|
205
|
+
mocks.mockGetCsrfToken.mockResolvedValue(newConfig.csrfToken);
|
|
206
|
+
}
|
|
207
|
+
if (newConfig.chainId !== undefined) {
|
|
208
|
+
// Update chainId in account mock
|
|
209
|
+
mocks.mockUseAccount.mockReturnValue({
|
|
210
|
+
address,
|
|
211
|
+
isConnected,
|
|
212
|
+
chainId: newConfig.chainId,
|
|
213
|
+
});
|
|
214
|
+
// Update chainId in SIWE mock
|
|
215
|
+
mocks.mockSiweMessage.mockImplementation(() => ({
|
|
216
|
+
address,
|
|
217
|
+
verify: vi.fn().mockResolvedValue({
|
|
218
|
+
success: siweVerificationSuccess,
|
|
219
|
+
data: { nonce: 'mock-nonce', chainId: newConfig.chainId },
|
|
220
|
+
}),
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
if (newConfig.siweVerificationSuccess !== undefined) {
|
|
224
|
+
mocks.mockSiweMessage.mockImplementation(() => ({
|
|
225
|
+
address,
|
|
226
|
+
verify: vi.fn().mockResolvedValue({
|
|
227
|
+
success: newConfig.siweVerificationSuccess,
|
|
228
|
+
data: { nonce: 'mock-nonce', chainId: newConfig.chainId ?? chainId },
|
|
229
|
+
}),
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
mocks,
|
|
235
|
+
setupMocks,
|
|
236
|
+
setupDefaultImplementations,
|
|
237
|
+
resetMocks,
|
|
238
|
+
updateConfig,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Pre-configured authentication mocks for API route tests
|
|
243
|
+
*/
|
|
244
|
+
export const apiAuthMocks = createAuthMocks();
|
|
245
|
+
/**
|
|
246
|
+
* Pre-configured authentication mocks for hook tests
|
|
247
|
+
*/
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viem mocking utilities for tests
|
|
3
|
+
*
|
|
4
|
+
* "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
|
|
5
|
+
*/
|
|
6
|
+
declare const viemMocks: {
|
|
7
|
+
createPublicClient: import("vitest").Mock<() => {
|
|
8
|
+
getTransactionReceipt: import("vitest").Mock<(...args: any[]) => any>;
|
|
9
|
+
getBlock: import("vitest").Mock<(...args: any[]) => any>;
|
|
10
|
+
}>;
|
|
11
|
+
createWalletClient: import("vitest").Mock<() => {
|
|
12
|
+
sendTransaction: import("vitest").Mock<(...args: any[]) => any>;
|
|
13
|
+
}>;
|
|
14
|
+
getContract: import("vitest").Mock<() => {
|
|
15
|
+
address: string;
|
|
16
|
+
read: {
|
|
17
|
+
vaults: import("vitest").Mock<(...args: any[]) => any>;
|
|
18
|
+
studentCanSubmit: import("vitest").Mock<(...args: any[]) => any>;
|
|
19
|
+
getStudentGuideStatus: import("vitest").Mock<(...args: any[]) => any>;
|
|
20
|
+
};
|
|
21
|
+
write: {
|
|
22
|
+
submitGuideResult: import("vitest").Mock<(...args: any[]) => any>;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
encodeFunctionData: import("vitest").Mock<() => string>;
|
|
26
|
+
decodeFunctionData: import("vitest").Mock<() => {
|
|
27
|
+
functionName: string;
|
|
28
|
+
args: never[];
|
|
29
|
+
}>;
|
|
30
|
+
parseUnits: import("vitest").Mock<(value: string) => bigint>;
|
|
31
|
+
http: import("vitest").Mock<() => {}>;
|
|
32
|
+
privateKeyToAccount: import("vitest").Mock<() => {
|
|
33
|
+
address: string;
|
|
34
|
+
}>;
|
|
35
|
+
formatUnits: import("vitest").Mock<(value: any, decimals: any) => string>;
|
|
36
|
+
Address: any;
|
|
37
|
+
Hex: any;
|
|
38
|
+
};
|
|
39
|
+
declare const viemChainsMocks: {
|
|
40
|
+
celo: {
|
|
41
|
+
id: number;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
44
|
+
celoSepolia: {
|
|
45
|
+
id: number;
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export { viemMocks, viemChainsMocks };
|
|
50
|
+
/**
|
|
51
|
+
* Mock for viem module
|
|
52
|
+
*/
|
|
53
|
+
export declare function mockViem(): {
|
|
54
|
+
createPublicClient: import("vitest").Mock<() => {
|
|
55
|
+
getTransactionReceipt: import("vitest").Mock<(...args: any[]) => any>;
|
|
56
|
+
getBlock: import("vitest").Mock<(...args: any[]) => any>;
|
|
57
|
+
}>;
|
|
58
|
+
createWalletClient: import("vitest").Mock<() => {
|
|
59
|
+
sendTransaction: import("vitest").Mock<(...args: any[]) => any>;
|
|
60
|
+
}>;
|
|
61
|
+
getContract: import("vitest").Mock<() => {
|
|
62
|
+
address: string;
|
|
63
|
+
read: {
|
|
64
|
+
vaults: import("vitest").Mock<(...args: any[]) => any>;
|
|
65
|
+
studentCanSubmit: import("vitest").Mock<(...args: any[]) => any>;
|
|
66
|
+
getStudentGuideStatus: import("vitest").Mock<(...args: any[]) => any>;
|
|
67
|
+
};
|
|
68
|
+
write: {
|
|
69
|
+
submitGuideResult: import("vitest").Mock<(...args: any[]) => any>;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
encodeFunctionData: import("vitest").Mock<() => string>;
|
|
73
|
+
decodeFunctionData: import("vitest").Mock<() => {
|
|
74
|
+
functionName: string;
|
|
75
|
+
args: never[];
|
|
76
|
+
}>;
|
|
77
|
+
parseUnits: import("vitest").Mock<(value: string) => bigint>;
|
|
78
|
+
http: import("vitest").Mock<() => {}>;
|
|
79
|
+
privateKeyToAccount: import("vitest").Mock<() => {
|
|
80
|
+
address: string;
|
|
81
|
+
}>;
|
|
82
|
+
formatUnits: import("vitest").Mock<(value: any, decimals: any) => string>;
|
|
83
|
+
Address: any;
|
|
84
|
+
Hex: any;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=viem-mocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viem-mocks.d.ts","sourceRoot":"","sources":["../../src/test-utils/viem-mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;8CAqBa,MAAM;;;;;+CAKL,GAAG,YAAY,GAAG;aAM5B,GAAG;SACP,GAAG;CACf,CAAA;AAEH,QAAA,MAAM,eAAe;;;;;;;;;CAGlB,CAAA;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAA;AAErC;;GAEG;AACH,wBAAgB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;8CAzBI,MAAM;;;;;+CAKL,GAAG,YAAY,GAAG;aAM5B,GAAG;SACP,GAAG;EAejB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viem mocking utilities for tests
|
|
3
|
+
*
|
|
4
|
+
* "Y todo lo que hagáis, hacedlo de corazón, como para el Señor y no para los hombres" (Colosenses 3:23)
|
|
5
|
+
*/
|
|
6
|
+
import { vi } from 'vitest';
|
|
7
|
+
// Mock objects defined with vi.hoisted for proper hoisting
|
|
8
|
+
const viemMocks = vi.hoisted(() => ({
|
|
9
|
+
createPublicClient: vi.fn(() => ({
|
|
10
|
+
getTransactionReceipt: vi.fn().mockResolvedValue({ status: 'success', blockNumber: 12345n }),
|
|
11
|
+
getBlock: vi.fn().mockResolvedValue({ number: 12347n }),
|
|
12
|
+
})),
|
|
13
|
+
createWalletClient: vi.fn(() => ({
|
|
14
|
+
sendTransaction: vi.fn().mockResolvedValue('0xmocktxhash'),
|
|
15
|
+
})),
|
|
16
|
+
getContract: vi.fn(() => ({
|
|
17
|
+
address: '0xmockContractAddress',
|
|
18
|
+
read: {
|
|
19
|
+
vaults: vi.fn().mockResolvedValue([0n, 0n, 0n, 0n, 0n, 1n]),
|
|
20
|
+
studentCanSubmit: vi.fn().mockResolvedValue(true),
|
|
21
|
+
getStudentGuideStatus: vi.fn().mockResolvedValue([0n, true]),
|
|
22
|
+
},
|
|
23
|
+
write: {
|
|
24
|
+
submitGuideResult: vi.fn().mockResolvedValue('0xmocktxhash'),
|
|
25
|
+
},
|
|
26
|
+
})),
|
|
27
|
+
encodeFunctionData: vi.fn(() => '0xmockEncodedData'),
|
|
28
|
+
decodeFunctionData: vi.fn(() => ({ functionName: 'deposit', args: [] })),
|
|
29
|
+
parseUnits: vi.fn((value) => BigInt(value)),
|
|
30
|
+
http: vi.fn(() => ({})),
|
|
31
|
+
privateKeyToAccount: vi.fn(() => ({
|
|
32
|
+
address: '0xmockAccount',
|
|
33
|
+
})),
|
|
34
|
+
formatUnits: vi.fn((value, decimals) => {
|
|
35
|
+
const str = value.toString();
|
|
36
|
+
const intLen = str.length;
|
|
37
|
+
if (intLen <= decimals)
|
|
38
|
+
return '0.' + '0'.repeat(decimals - intLen) + str;
|
|
39
|
+
return str.slice(0, intLen - decimals) + '.' + str.slice(intLen - decimals);
|
|
40
|
+
}),
|
|
41
|
+
Address: '0x',
|
|
42
|
+
Hex: '0x',
|
|
43
|
+
}));
|
|
44
|
+
const viemChainsMocks = vi.hoisted(() => ({
|
|
45
|
+
celo: { id: 42220, name: 'Celo' },
|
|
46
|
+
celoSepolia: { id: 44787, name: 'Celo Sepolia' },
|
|
47
|
+
}));
|
|
48
|
+
export { viemMocks, viemChainsMocks };
|
|
49
|
+
/**
|
|
50
|
+
* Mock for viem module
|
|
51
|
+
*/
|
|
52
|
+
export function mockViem() {
|
|
53
|
+
return viemMocks;
|
|
54
|
+
}
|