Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha committed Feb 21, 2024
1 parent 41cf908 commit df12f45
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 0 deletions.
137 changes: 137 additions & 0 deletions ui/components/multichain/account-list-menu/account-list-menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,44 @@ jest.mock('../../../../app/scripts/lib/util', () => ({
const render = (props = { onClose: () => jest.fn() }) => {
const store = configureStore({
...mockState,
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
},
activeTab: {
id: 113,
title: 'E2E Test Dapp',
origin: 'https://metamask.github.io',
protocol: 'https:',
url: 'https://metamask.github.io/test-dapp/',
},
unconnectedAccount: {
state: 'OPEN',
},
});
return renderWithProvider(<AccountListMenu {...props} />, store);
};
Expand Down Expand Up @@ -96,8 +127,36 @@ describe('AccountListMenu', () => {
protocol: 'https:',
url: 'https://remix.ethereum.org/',
},
unconnectedAccount: {
state: 'OPEN',
},
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
balance: '0x346ba7725f412cbfdb',
Expand Down Expand Up @@ -200,6 +259,31 @@ describe('AccountListMenu', () => {
metamask: {
...mockState.metamask,
...state,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
},
},
activeTab: {
Expand Down Expand Up @@ -273,8 +357,36 @@ describe('AccountListMenu', () => {
protocol: 'https:',
url: 'https://remix.ethereum.org/',
},
unconnectedAccount: {
state: 'OPEN',
},
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
internalAccounts: {
...mockState.metamask.internalAccounts,
accounts: {
Expand Down Expand Up @@ -312,6 +424,31 @@ describe('AccountListMenu', () => {
},
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
internalAccounts: {
...mockState.metamask.internalAccounts,
accounts: {
Expand Down
36 changes: 36 additions & 0 deletions ui/selectors/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,37 @@ describe('Selectors', () => {
balance: '0x0',
},
},
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
},
activeTab: {
origin: 'https://test.dapp',
},
unconnectedAccount: {
state: 'OPEN',
},
};
const expectedResult = [
Expand All @@ -1043,6 +1074,7 @@ describe('Selectors', () => {
balance: '0x0',
pinned: true,
hidden: false,
active: false,
},
{
name: 'Test Account 3',
Expand All @@ -1067,6 +1099,7 @@ describe('Selectors', () => {
balance: '0x0',
pinned: true,
hidden: false,
active: false,
},
{
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
Expand All @@ -1091,6 +1124,7 @@ describe('Selectors', () => {
balance: '0x0',
pinned: false,
hidden: false,
active: true,
},
{
address: '0xc42edfcc21ed14dda456aa0756c153f7985d8813',
Expand All @@ -1115,6 +1149,7 @@ describe('Selectors', () => {
balance: '0x0',
pinned: false,
hidden: false,
active: false,
},
{
name: 'Custody test',
Expand All @@ -1139,6 +1174,7 @@ describe('Selectors', () => {
balance: '0x0',
pinned: false,
hidden: false,
active: false,
},
];
expect(
Expand Down

0 comments on commit df12f45

Please sign in to comment.