2021-04-05 15:50:55 +00:00
|
|
|
import * as modals from './ui/components/modals';
|
|
|
|
import type { ErrorModalOptions } from './ui/components/modals/error-modal';
|
2021-06-02 01:46:26 +00:00
|
|
|
import { PromptModalOptions } from './ui/components/modals/prompt-modal';
|
2021-04-05 15:50:55 +00:00
|
|
|
|
2021-06-02 01:46:26 +00:00
|
|
|
export const getAndClearShowPromptMockArgs = (): PromptModalOptions => {
|
2021-05-12 06:35:00 +00:00
|
|
|
const mockFn = modals.showPrompt as jest.Mock;
|
2021-06-02 01:46:26 +00:00
|
|
|
const options = mockFn.mock.calls[0][0] as PromptModalOptions;
|
2021-04-05 15:50:55 +00:00
|
|
|
mockFn.mockClear();
|
2021-06-02 01:46:26 +00:00
|
|
|
return options;
|
2021-04-05 15:50:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const getAndClearShowAlertMockArgs = () => {
|
2021-05-12 06:35:00 +00:00
|
|
|
const mockFn = modals.showAlert as jest.Mock;
|
2021-04-05 15:50:55 +00:00
|
|
|
const { title, okLabel, addCancel, message, onConfirm } = mockFn.mock.calls[0][0];
|
|
|
|
mockFn.mockClear();
|
2021-05-12 06:35:00 +00:00
|
|
|
return {
|
|
|
|
title,
|
|
|
|
okLabel,
|
|
|
|
addCancel,
|
|
|
|
message,
|
|
|
|
onConfirm,
|
|
|
|
};
|
2021-04-05 15:50:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const getAndClearShowErrorMockArgs = (): ErrorModalOptions => {
|
2021-05-12 06:35:00 +00:00
|
|
|
const mockFn = modals.showError as jest.Mock;
|
2021-04-05 15:50:55 +00:00
|
|
|
const options: ErrorModalOptions = mockFn.mock.calls[0][0];
|
|
|
|
mockFn.mockClear();
|
|
|
|
return options;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getAndClearShowModalMockArgs = () => {
|
2021-05-12 06:35:00 +00:00
|
|
|
const mockFn = modals.showModal as jest.Mock;
|
2021-04-05 15:50:55 +00:00
|
|
|
const args = mockFn.mock.calls[0][1];
|
|
|
|
mockFn.mockClear();
|
|
|
|
return args;
|
|
|
|
};
|