Add default safe test

This commit is contained in:
mmv 2019-09-23 18:53:13 +04:00
parent 0fd579f6b7
commit 957c06879f
2 changed files with 27 additions and 1 deletions

View File

@ -72,6 +72,7 @@ export const aMinedSafe = async (
store: Store<GlobalState>,
owners: number = 1,
threshold: number = 1,
name: string = 'Safe Name',
): Promise<string> => {
const provider = await getProviderInfo()
const walletRecord = makeProvider(provider)
@ -79,7 +80,7 @@ export const aMinedSafe = async (
const accounts = await getWeb3().eth.getAccounts()
const form = {
[FIELD_NAME]: 'Safe Name',
[FIELD_NAME]: name,
[FIELD_CONFIRMATIONS]: `${threshold}`,
[FIELD_OWNERS]: `${owners}`,
}

View File

@ -6,6 +6,7 @@ import { renderSafeView } from '~/test/builder/safe.dom.utils'
import '@testing-library/jest-dom/extend-expect'
import { TOGGLE_SIDEBAR_BTN_TESTID } from '~/components/Header/component/SafeListHeader'
import { SIDEBAR_SAFELIST_ROW_TESTID } from '~/components/Sidebar/SafeList'
import { sleep } from '~/utils/timer'
describe('DOM > Feature > Sidebar', () => {
let store
@ -27,4 +28,28 @@ describe('DOM > Feature > Sidebar', () => {
expect(safes[0]).toContainElement(SafeDom.getByText('default'))
})
it('Changes default safe', async () => {
const SafeDom = await renderSafeView(store, safeAddress)
await aMinedSafe(store)
await sleep(2000)
act(() => {
fireEvent.click(SafeDom.getByTestId(TOGGLE_SIDEBAR_BTN_TESTID))
})
const safes = SafeDom.getAllByTestId(SIDEBAR_SAFELIST_ROW_TESTID)
expect(safes.length).toBe(2)
expect(safes[1]).toContainElement(SafeDom.getByText('default'))
expect(safes[0]).toContainElement(SafeDom.getByText('Make default'))
act(() => {
fireEvent.click(SafeDom.getByText('Make default'))
})
expect(safes[0]).toContainElement(SafeDom.getByText('default'))
expect(safes[1]).toContainElement(SafeDom.getByText('Make default'))
})
})