mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { ApprovalType } from '@metamask/controller-utils';
|
|
import { hasPendingApprovals } from './approvals';
|
|
|
|
describe('approval selectors', () => {
|
|
const mockedState = {
|
|
metamask: {
|
|
pendingApprovalCount: 3,
|
|
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,
|
|
requestData: {},
|
|
requestState: null,
|
|
},
|
|
},
|
|
unapprovedTxs: {
|
|
'2': {
|
|
id: '2',
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
describe('hasPendingApprovals', () => {
|
|
it('should return true if there is a pending approval request', () => {
|
|
const result = hasPendingApprovals(mockedState, ApprovalType.WatchAsset);
|
|
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it('should return false if there is no pending approval request', () => {
|
|
const result = hasPendingApprovals(
|
|
mockedState,
|
|
ApprovalType.SnapDialogPrompt,
|
|
);
|
|
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
});
|