You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.0 KiB
64 lines
2.0 KiB
4 years ago
|
import React from 'react';
|
||
|
import { Provider } from 'react-redux';
|
||
|
import configureStore from 'redux-mock-store';
|
||
4 years ago
|
import { mountWithRouter } from '../../../../test/lib/render-helpers';
|
||
|
import { ROPSTEN_CHAIN_ID } from '../../../../shared/constants/network';
|
||
4 years ago
|
import MenuBar from './menu-bar';
|
||
5 years ago
|
|
||
5 years ago
|
const initState = {
|
||
4 years ago
|
activeTab: {},
|
||
5 years ago
|
metamask: {
|
||
4 years ago
|
provider: {
|
||
|
chainId: ROPSTEN_CHAIN_ID,
|
||
|
},
|
||
5 years ago
|
selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||
|
identities: {
|
||
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
|
||
|
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||
|
name: 'Account 1',
|
||
5 years ago
|
},
|
||
|
},
|
||
5 years ago
|
keyrings: [
|
||
|
{
|
||
|
type: 'HD Key Tree',
|
||
4 years ago
|
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
||
5 years ago
|
},
|
||
5 years ago
|
],
|
||
|
frequentRpcListDetail: [],
|
||
|
},
|
||
4 years ago
|
};
|
||
|
const mockStore = configureStore();
|
||
5 years ago
|
|
||
4 years ago
|
describe('MenuBar', () => {
|
||
|
it('opens account detail menu when account options is clicked', () => {
|
||
4 years ago
|
const store = mockStore(initState);
|
||
5 years ago
|
const wrapper = mountWithRouter(
|
||
5 years ago
|
<Provider store={store}>
|
||
5 years ago
|
<MenuBar />
|
||
4 years ago
|
</Provider>,
|
||
4 years ago
|
);
|
||
4 years ago
|
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
||
4 years ago
|
const accountOptions = wrapper.find('.menu-bar__account-options');
|
||
|
accountOptions.simulate('click');
|
||
|
wrapper.update();
|
||
4 years ago
|
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('sets accountDetailsMenuOpen to false when closed', () => {
|
||
4 years ago
|
const store = mockStore(initState);
|
||
5 years ago
|
const wrapper = mountWithRouter(
|
||
|
<Provider store={store}>
|
||
|
<MenuBar />
|
||
4 years ago
|
</Provider>,
|
||
4 years ago
|
);
|
||
|
const accountOptions = wrapper.find('.menu-bar__account-options');
|
||
|
accountOptions.simulate('click');
|
||
|
wrapper.update();
|
||
4 years ago
|
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
||
4 years ago
|
const accountDetailsMenu = wrapper.find('AccountOptionsMenu');
|
||
|
accountDetailsMenu.prop('onClose')();
|
||
|
wrapper.update();
|
||
4 years ago
|
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
|
});
|