-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/update-post-saga-to-support-media-uploa…
…ds-create-optimistic-posts-handle-media-mapping-in-events-and-update-send-post-tests-for-full-functionality
- Loading branch information
Showing
15 changed files
with
278 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,19 @@ import { Properties, AccountManagementPanel } from '.'; | |
import { PanelHeader } from '../../list/panel-header'; | ||
import { bem } from '../../../../lib/bem'; | ||
import { Button } from '@zero-tech/zui/components/Button'; | ||
import { ConnectButton } from '@rainbow-me/rainbowkit'; | ||
|
||
const featureFlags = { enableAddWallets: true }; | ||
jest.mock('../../../../lib/feature-flags', () => ({ | ||
featureFlags: featureFlags, | ||
})); | ||
|
||
// Mock the ConnectButton from rainbowkit | ||
jest.mock('@rainbow-me/rainbowkit', () => ({ | ||
ConnectButton: { | ||
Custom: ({ children }) => children({ account: { address: '0x123' }, openConnectModal: jest.fn() }), | ||
}, | ||
})); | ||
|
||
const c = bem('.account-management-panel'); | ||
|
||
|
@@ -15,6 +28,8 @@ describe(AccountManagementPanel, () => { | |
isAddEmailModalOpen: false, | ||
currentUser: {}, | ||
canAddEmail: false, | ||
isWalletConnected: false, | ||
connectedWallet: '', | ||
|
||
onBack: () => {}, | ||
onOpenAddEmailModal: () => {}, | ||
|
@@ -182,4 +197,47 @@ describe(AccountManagementPanel, () => { | |
expect(onCloseAddEmailModal).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('link new wallet', () => { | ||
it('should render Add Wallet button if user has no wallet linked to his ZERO account', () => { | ||
const wrapper = subject({ currentUser: { primaryEmail: '[email protected]', wallets: [] } }); | ||
|
||
expect(wrapper.find(ConnectButton.Custom).exists()).toEqual(true); | ||
}); | ||
|
||
it('should not render Add Wallet button if user has a wallet linked to his ZERO account', () => { | ||
const wrapper = subject({ currentUser: { primaryEmail: '[email protected]', wallets: [{ id: 'wallet-id-1' }] } }); | ||
expect(wrapper.find(ConnectButton.Custom).exists()).toEqual(false); | ||
}); | ||
|
||
it('should open Link Wallet modal when user clicks on Add Wallet, and metamask is connected', () => { | ||
const wrapper = subject({ | ||
currentUser: { primaryEmail: '[email protected]', wallets: [] }, | ||
isWalletConnected: true, | ||
connectedWallet: '0xA100C16E67884Da7d515211Bb065592079bEcde6', | ||
}); | ||
|
||
wrapper.setState({ isUserLinkingNewWallet: true }); | ||
|
||
const linkWalletModal = wrapper.find('Modal').at(1); | ||
expect(linkWalletModal.exists()).toEqual(true); | ||
expect(linkWalletModal.prop('title')).toEqual('Link Wallet'); | ||
expect(linkWalletModal.find(c('link-new-wallet-modal')).text()).toEqual( | ||
'You have a wallet connected by the address 0xA100C16E67884Da7d515211Bb065592079bEcde6Do you want to link this wallet with your ZERO account?' | ||
); | ||
}); | ||
|
||
it('should update isUserLinkingNewWallet state to false when user closes Link Wallet modal', () => { | ||
const wrapper = subject({ | ||
currentUser: { primaryEmail: '[email protected]', wallets: [] }, | ||
isWalletConnected: true, | ||
}); | ||
|
||
wrapper.setState({ isUserLinkingNewWallet: true }); | ||
|
||
const linkWalletModal = wrapper.find('Modal').at(1); | ||
(linkWalletModal as any).props().onClose(); | ||
expect(wrapper.state('isUserLinkingNewWallet')).toEqual(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.