1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/selectors/approvals.test.ts

51 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-04-25 11:47:49 +02:00
import { ApprovalType } from '@metamask/controller-utils';
import { hasPendingApprovals } from './approvals';
2023-04-25 11:47:49 +02:00
describe('approval selectors', () => {
const mockedState = {
metamask: {
pendingApprovalCount: 3,
2023-04-25 11:47:49 +02:00
pendingApprovals: {
'1': {
id: '1',
origin: 'origin',
time: Date.now(),
type: ApprovalType.WatchAsset,
requestData: {},
requestState: null,
},
'2': {
id: '2',
origin: 'origin',
time: Date.now(),
type: ApprovalType.Transaction,
2023-04-25 11:47:49 +02:00
requestData: {},
requestState: null,
},
},
unapprovedTxs: {
'2': {
id: '2',
},
},
2023-04-25 11:47:49 +02:00
},
};
describe('hasPendingApprovals', () => {
2023-04-25 11:47:49 +02:00
it('should return true if there is a pending approval request', () => {
const result = hasPendingApprovals(mockedState, ApprovalType.WatchAsset);
2023-04-25 11:47:49 +02:00
expect(result).toBe(true);
});
it('should return false if there is no pending approval request', () => {
const result = hasPendingApprovals(
2023-04-25 11:47:49 +02:00
mockedState,
ApprovalType.SnapDialogPrompt,
2023-04-25 11:47:49 +02:00
);
expect(result).toBe(false);
});
});
});