mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 15:50:28 +01:00
a8e194a8f6
* removed recents and added accounts in send flow * updated add contact button and fixed full screen view * updated ui for contacts * fixed lint errors and test * fixed lint errors * fixed lint errors * updated spec files * fixed lint errors * updated snapshot * fixed edit in spec files * removed unused console statement * updated snapshot * added userInput check * updated snapshot and added hover
85 lines
2.8 KiB
JavaScript
85 lines
2.8 KiB
JavaScript
let mapStateToProps;
|
|
let mapDispatchToProps;
|
|
|
|
jest.mock('react-redux', () => ({
|
|
connect: (ms, md) => {
|
|
mapStateToProps = ms;
|
|
mapDispatchToProps = md;
|
|
return () => ({});
|
|
},
|
|
}));
|
|
|
|
jest.mock('../../../../selectors', () => ({
|
|
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
|
|
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
|
|
getMetaMaskAccountsOrdered: () => [
|
|
{ name: `account1:mockState` },
|
|
{ name: `account2:mockState` },
|
|
],
|
|
currentNetworkTxListSelector: (s) => `currentNetworkTxListSelector:${s}`,
|
|
}));
|
|
|
|
jest.mock('../../../../ducks/domains', () => ({
|
|
getDomainResolution: (s) => `mockSendDomainResolution:${s}`,
|
|
getDomainError: (s) => `mockSendDomainResolutionError:${s}`,
|
|
getDomainWarning: (s) => `mockSendDomainResolutionWarning:${s}`,
|
|
useMyAccountsForRecipientSearch: (s) =>
|
|
`useMyAccountsForRecipientSearch:${s}`,
|
|
}));
|
|
|
|
jest.mock('../../../../ducks/send', () => ({
|
|
updateRecipient: ({ address, nickname }) =>
|
|
`{mockUpdateRecipient: {address: ${address}, nickname: ${nickname}}}`,
|
|
updateRecipientUserInput: (s) => `mockUpdateRecipientUserInput:${s}`,
|
|
useMyAccountsForRecipientSearch: (s) =>
|
|
`mockUseMyAccountsForRecipientSearch:${s}`,
|
|
useContactListForRecipientSearch: (s) =>
|
|
`mockUseContactListForRecipientSearch:${s}`,
|
|
getRecipientUserInput: (s) => `mockRecipientUserInput:${s}`,
|
|
getRecipient: (s) => `mockRecipient:${s}`,
|
|
}));
|
|
|
|
require('./add-recipient.container');
|
|
|
|
describe('add-recipient container', () => {
|
|
describe('mapStateToProps()', () => {
|
|
it('should map the correct properties to props', () => {
|
|
expect(mapStateToProps('mockState')).toStrictEqual({
|
|
addressBook: [{ name: 'mockAddressBook:mockState' }],
|
|
addressBookEntryName: undefined,
|
|
contacts: [{ name: 'mockAddressBook:mockState' }],
|
|
domainResolution: 'mockSendDomainResolution:mockState',
|
|
domainError: 'mockSendDomainResolutionError:mockState',
|
|
domainWarning: 'mockSendDomainResolutionWarning:mockState',
|
|
nonContacts: [],
|
|
ownedAccounts: [
|
|
{ name: 'account1:mockState' },
|
|
{ name: 'account2:mockState' },
|
|
],
|
|
userInput: 'mockRecipientUserInput:mockState',
|
|
recipient: 'mockRecipient:mockState',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('mapDispatchToProps()', () => {
|
|
describe('updateRecipient()', () => {
|
|
const dispatchSpy = jest.fn();
|
|
|
|
const mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
|
|
|
|
it('should dispatch an action', () => {
|
|
mapDispatchToPropsObject.updateRecipient({
|
|
address: 'mockAddress',
|
|
nickname: 'mockNickname',
|
|
});
|
|
|
|
expect(dispatchSpy).toHaveBeenCalledTimes(1);
|
|
expect(dispatchSpy.mock.calls[0][0]).toStrictEqual(
|
|
'{mockUpdateRecipient: {address: mockAddress, nickname: mockNickname}}',
|
|
);
|
|
});
|
|
});
|
|
});
|
|
});
|