mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
5f4c19da35
Co-authored-by: Opender Singh <opender.singh@konghq.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import * as modals from './ui/components/modals';
|
|
import type { ErrorModalOptions } from './ui/components/modals/error-modal';
|
|
|
|
export const getAndClearShowPromptMockArgs = () => {
|
|
const mockFn = modals.showPrompt as jest.Mock;
|
|
const { title, submitName, defaultValue, onComplete } = mockFn.mock.calls[0][0];
|
|
mockFn.mockClear();
|
|
return {
|
|
title,
|
|
submitName,
|
|
defaultValue,
|
|
onComplete,
|
|
};
|
|
};
|
|
|
|
export const getAndClearShowAlertMockArgs = () => {
|
|
const mockFn = modals.showAlert as jest.Mock;
|
|
const { title, okLabel, addCancel, message, onConfirm } = mockFn.mock.calls[0][0];
|
|
mockFn.mockClear();
|
|
return {
|
|
title,
|
|
okLabel,
|
|
addCancel,
|
|
message,
|
|
onConfirm,
|
|
};
|
|
};
|
|
|
|
export const getAndClearShowErrorMockArgs = (): ErrorModalOptions => {
|
|
const mockFn = modals.showError as jest.Mock;
|
|
const options: ErrorModalOptions = mockFn.mock.calls[0][0];
|
|
mockFn.mockClear();
|
|
return options;
|
|
};
|
|
|
|
export const getAndClearShowModalMockArgs = () => {
|
|
const mockFn = modals.showModal as jest.Mock;
|
|
const args = mockFn.mock.calls[0][1];
|
|
mockFn.mockClear();
|
|
return args;
|
|
};
|