Skip to content

Commit

Permalink
use DefaultSnapInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Jun 28, 2024
1 parent 1c412a6 commit 0238f1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
22 changes: 11 additions & 11 deletions packages/snaps-jest/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import type {
SnapInterfaceActions,
SnapConfirmationInterface,
SnapPromptInterface,
SnapDefaultInterface,
SnapDefaultInterfaceWithFooter,
SnapDefaultInterfaceWithPartialFooter,
SnapDefaultInterfaceWithoutFooter,
DefaultSnapInterface,
DefaultSnapInterfaceWithFooter,
DefaultSnapInterfaceWithPartialFooter,
DefaultSnapInterfaceWithoutFooter,
} from './types';

const log = createModuleLogger(rootLogger, 'helpers');
Expand Down Expand Up @@ -118,7 +118,7 @@ export function assertIsPromptDialog(
*/
export function assertIsCustomDialog(
ui: SnapInterface,
): asserts ui is SnapDefaultInterface & SnapInterfaceActions {
): asserts ui is DefaultSnapInterface & SnapInterfaceActions {
assert(!hasProperty(ui, 'type'));
}

Expand All @@ -128,8 +128,8 @@ export function assertIsCustomDialog(
* @param ui - The interface to verify.
*/
export function assertCustomDialogHasFooter(
ui: SnapDefaultInterface & SnapInterfaceActions,
): asserts ui is SnapDefaultInterfaceWithFooter & SnapInterfaceActions {
ui: DefaultSnapInterface & SnapInterfaceActions,
): asserts ui is DefaultSnapInterfaceWithFooter & SnapInterfaceActions {
const footer = getElementByType<FooterElement>(ui.content, 'Footer');

assert(footer && getJsxChildren(footer).length === 2);
Expand All @@ -141,8 +141,8 @@ export function assertCustomDialogHasFooter(
* @param ui - The interface to verify.
*/
export function assertCustomDialogHasPartialFooter(
ui: SnapDefaultInterface & SnapInterfaceActions,
): asserts ui is SnapDefaultInterfaceWithPartialFooter & SnapInterfaceActions {
ui: DefaultSnapInterface & SnapInterfaceActions,
): asserts ui is DefaultSnapInterfaceWithPartialFooter & SnapInterfaceActions {
const footer = getElementByType<FooterElement>(ui.content, 'Footer');

assert(footer && getJsxChildren(footer).length === 1);
Expand All @@ -154,8 +154,8 @@ export function assertCustomDialogHasPartialFooter(
* @param ui - The interface to verify.
*/
export function assertCustomDialogHasNoFooter(
ui: SnapDefaultInterface & SnapInterfaceActions,
): asserts ui is SnapDefaultInterfaceWithoutFooter & SnapInterfaceActions {
ui: DefaultSnapInterface & SnapInterfaceActions,
): asserts ui is DefaultSnapInterfaceWithoutFooter & SnapInterfaceActions {
const footer = getElementByType<FooterElement>(ui.content, 'Footer');

assert(!footer);
Expand Down
17 changes: 9 additions & 8 deletions packages/snaps-jest/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export type SnapPromptInterface = {
* A `snap_dialog` default interface that has a Footer with two buttons defined.
* The approval of this confirmation is handled by the snap.
*/
type DefaultSnapInterfaceWithFooter = {
export type DefaultSnapInterfaceWithFooter = {
/**
* The content to show in the interface.
*/
Expand All @@ -231,18 +231,19 @@ type DefaultSnapInterfaceWithFooter = {
* A `snap_dialog` default interface that has a Footer with one button defined.
* A cancel button is automatically applied to the interface in this case.
*/
type DefaultSnapInterfaceWithPartialFooter = DefaultSnapInterfaceWithFooter & {
/**
* Cancel the dialog.
*/
cancel(): Promise<void>;
};
export type DefaultSnapInterfaceWithPartialFooter =
DefaultSnapInterfaceWithFooter & {
/**
* Cancel the dialog.
*/
cancel(): Promise<void>;
};

/**
* A `snap_dialog` default interface that has no Footer defined.
* A cancel and ok button is automatically applied to the interface in this case.
*/
type DefaultSnapInterfaceWithoutFooter =
export type DefaultSnapInterfaceWithoutFooter =
DefaultSnapInterfaceWithPartialFooter & {
/**
* Close the dialog.
Expand Down

0 comments on commit 0238f1c

Please sign in to comment.