Skip to content

Commit

Permalink
working footer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Cross committed Feb 4, 2025
1 parent 9e9ea6c commit 8537e3c
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ import { ButtonElement, FooterElement } from '@metamask/snaps-sdk/jsx';
import { footer, DEFAULT_FOOTER } from '../components/footer';
import { ButtonVariant } from '@metamask/snaps-sdk';

jest.mock('@metamask/snaps-utils', () => ({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getJsxChildren: (e: any) => {
const children = e.props.children;
return Array.isArray(children) ? children : [children].filter(Boolean);
},
}));

describe('footer', () => {
const mockT = (value: string) => `translated_${value}`;
const mockOnCancel = jest.fn();
Expand Down Expand Up @@ -59,10 +51,19 @@ describe('footer', () => {
element: 'SnapUIFooterButton',
key: 'snap-footer-button-0',
props: {
children: ['Button'],
disabled: undefined,
form: undefined,
isSnapAction: true,
label: ['Button'],
loading: false,
name: undefined,
onCancel: undefined,
onConfirm: undefined,
textVariant: 'sBodyMD',
type: 'Button',
variant: 'primary',
},
children: ['Button'],
},
],
});
Expand All @@ -81,16 +82,15 @@ describe('footer', () => {
});

expect(Array.isArray(result.children)).toBe(true);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((result.children as any[])[0]).toEqual({
element: 'SnapUIFooterButton',
element: 'BottomSheetFooter',
key: 'default-button',
props: {
onCancel: mockOnCancel,
variant: ButtonVariant.Secondary,
isSnapAction: false,
label: 'translated_template_confirmation.cancel',
onCancel: mockOnCancel,
variant: 'secondary',
},
children: 'translated_cancel',
});
});

Expand Down

0 comments on commit 8537e3c

Please sign in to comment.