mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import configureMockStore from 'redux-mock-store';
|
|
import thunk from 'redux-thunk';
|
|
import { waitFor } from '@testing-library/react';
|
|
|
|
import { ApprovalType } from '@metamask/controller-utils';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import Confirmation from '../confirmation';
|
|
|
|
jest.mock('../../../../shared/lib/fetch-with-cache');
|
|
|
|
const middleware = [thunk];
|
|
const mockApprovalId = 1;
|
|
const mockApproval = {
|
|
id: mockApprovalId,
|
|
origin: 'https://test-dapp.metamask.io',
|
|
requestData: {
|
|
header: [
|
|
{
|
|
key: 'headerText',
|
|
element: 'Typography',
|
|
children: 'Success mock',
|
|
props: {
|
|
variant: 'h2',
|
|
class: 'header-mock-class',
|
|
},
|
|
},
|
|
],
|
|
message: 'Success message',
|
|
},
|
|
};
|
|
|
|
const mockBaseStore = {
|
|
metamask: {
|
|
pendingApprovals: {
|
|
[mockApprovalId]: mockApproval,
|
|
},
|
|
approvalFlows: [],
|
|
subjectMetadata: {},
|
|
},
|
|
};
|
|
|
|
describe('success template', () => {
|
|
it('matches the snapshot', async () => {
|
|
const testStore = {
|
|
metamask: {
|
|
...mockBaseStore.metamask,
|
|
pendingApprovals: {
|
|
[mockApprovalId]: {
|
|
...mockApproval,
|
|
type: ApprovalType.ResultSuccess,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
const store = configureMockStore(middleware)(testStore);
|
|
const { getByText, container } = renderWithProvider(
|
|
<Confirmation />,
|
|
store,
|
|
);
|
|
await waitFor(() => {
|
|
expect(getByText('Success mock')).toBeInTheDocument();
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
});
|
|
});
|