2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import configureStore from 'redux-mock-store';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { mountWithRouter } from '../../../../test/lib/render-helpers';
|
|
|
|
import { ROPSTEN_CHAIN_ID } from '../../../../shared/constants/network';
|
2021-03-16 22:00:08 +01:00
|
|
|
import MenuBar from './menu-bar';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2020-04-01 18:35:07 +02:00
|
|
|
const initState = {
|
2020-07-10 17:46:54 +02:00
|
|
|
activeTab: {},
|
2020-04-01 18:35:07 +02:00
|
|
|
metamask: {
|
2021-03-10 18:21:52 +01:00
|
|
|
provider: {
|
|
|
|
chainId: ROPSTEN_CHAIN_ID,
|
|
|
|
},
|
2020-04-01 18:35:07 +02:00
|
|
|
selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
|
|
|
identities: {
|
|
|
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
|
|
|
|
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
|
|
|
name: 'Account 1',
|
2020-01-30 20:34:45 +01:00
|
|
|
},
|
|
|
|
},
|
2020-04-01 18:35:07 +02:00
|
|
|
keyrings: [
|
|
|
|
{
|
|
|
|
type: 'HD Key Tree',
|
2020-11-03 00:41:28 +01:00
|
|
|
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
2020-01-30 20:34:45 +01:00
|
|
|
},
|
2020-04-01 18:35:07 +02:00
|
|
|
],
|
|
|
|
frequentRpcListDetail: [],
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
const mockStore = configureStore();
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('MenuBar', () => {
|
|
|
|
it('opens account detail menu when account options is clicked', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const store = mockStore(initState);
|
2020-04-01 18:35:07 +02:00
|
|
|
const wrapper = mountWithRouter(
|
2020-01-30 20:34:45 +01:00
|
|
|
<Provider store={store}>
|
2020-04-01 18:35:07 +02:00
|
|
|
<MenuBar />
|
2020-07-14 17:20:41 +02:00
|
|
|
</Provider>,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
const accountOptions = wrapper.find('.menu-bar__account-options');
|
|
|
|
accountOptions.simulate('click');
|
|
|
|
wrapper.update();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('sets accountDetailsMenuOpen to false when closed', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const store = mockStore(initState);
|
2020-04-01 18:35:07 +02:00
|
|
|
const wrapper = mountWithRouter(
|
|
|
|
<Provider store={store}>
|
|
|
|
<MenuBar />
|
2020-07-14 17:20:41 +02:00
|
|
|
</Provider>,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const accountOptions = wrapper.find('.menu-bar__account-options');
|
|
|
|
accountOptions.simulate('click');
|
|
|
|
wrapper.update();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
const accountDetailsMenu = wrapper.find('AccountOptionsMenu');
|
|
|
|
accountDetailsMenu.prop('onClose')();
|
|
|
|
wrapper.update();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|