)
}
diff --git a/src/containers/shared/components/Notification/index.tsx b/src/containers/shared/components/Notification/index.tsx
index 5ebc5ec92..fdece5909 100755
--- a/src/containers/shared/components/Notification/index.tsx
+++ b/src/containers/shared/components/Notification/index.tsx
@@ -43,7 +43,7 @@ export const Notification = ({
' ',
)
return !dismissed ? (
-
+
{message}
{action}
diff --git a/src/containers/shared/components/Notification/tests/Notification.test.tsx b/src/containers/shared/components/Notification/tests/Notification.test.tsx
new file mode 100755
index 000000000..fd07556af
--- /dev/null
+++ b/src/containers/shared/components/Notification/tests/Notification.test.tsx
@@ -0,0 +1,100 @@
+import { cleanup, render, screen } from '@testing-library/react'
+import { Notification } from '../index'
+
+/* eslint-disable react/jsx-props-no-spreading */
+const VALID_USAGES = [
+ 'default',
+ 'success',
+ 'warning',
+ 'danger',
+ 'dark',
+ 'light',
+ 'dark50',
+]
+const notificationLevels = ['primary', 'secondary', 'ghost']
+const message = 'A catchy message'
+
+const renderComponent = (props) => render(
)
+
+describe('
', () => {
+ afterEach(cleanup)
+
+ it('renders without crashing', () => {
+ render(
)
+ })
+
+ it('should render with custom className', () => {
+ const className = 'test-class'
+ renderComponent({
+ message,
+ className,
+ })
+ expect(screen.getByText(message).parentElement).toHaveClass(className)
+ })
+
+ it('should render the action button', () => {
+ const action =
+ renderComponent({
+ message,
+ action,
+ })
+
+ expect(screen.queryByRole('button')).toBeDefined()
+ })
+
+ it('should render its message', () => {
+ const { container } = renderComponent({
+ message,
+ })
+
+ expect(container).toHaveTextContent(message)
+ })
+
+ // test all notification levels
+ notificationLevels.map((level) => {
+ it(`should accept level prop of ${level}`, () => {
+ renderComponent({
+ level,
+ message,
+ })
+ expect(screen.getByText(message).parentElement).toHaveClass(
+ `notification default ${level}-theme`,
+ )
+ })
+
+ return false
+ })
+
+ // test all notification usages
+ VALID_USAGES.map((usage) => {
+ it(`should render with usage prop of ${usage}`, () => {
+ renderComponent({
+ usage,
+ message,
+ })
+ expect(screen.getByText(message).parentElement).toHaveClass(usage)
+ })
+
+ return false
+ })
+
+ it('disappears', (done) => {
+ const { container } = render(
+
,
+ )
+ expect(container.innerHTML).toBe(
+ '
boo!
',
+ )
+
+ setTimeout(() => {
+ expect(container.innerHTML).toBe('')
+ done()
+ }, 200)
+ })
+})
diff --git a/src/containers/shared/components/Notification/tests/index.test.tsx b/src/containers/shared/components/Notification/tests/index.test.tsx
deleted file mode 100755
index 1b55671fc..000000000
--- a/src/containers/shared/components/Notification/tests/index.test.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { mount } from 'enzyme'
-import { Notification } from '../index'
-
-/* eslint-disable react/jsx-props-no-spreading */
-const VALID_USAGES = [
- 'default',
- 'success',
- 'warning',
- 'danger',
- 'dark',
- 'light',
- 'dark50',
-]
-const notificationLevels = ['primary', 'secondary', 'ghost']
-const message = 'A catchy message'
-const renderComponent = (props) => mount(
)
-
-describe('
', () => {
- it('should render with custom className', () => {
- const className = 'test-class'
- const wrapper = renderComponent({
- message,
- className,
- })
-
- expect(wrapper.hasClass(className)).toEqual(true)
- })
-
- it('should render the action button', () => {
- const action =
- const wrapper = renderComponent({
- message,
- action,
- })
-
- expect(wrapper.containsMatchingElement(action)).toEqual(true)
- })
-
- it('should render its message', () => {
- const wrapper = renderComponent({
- message,
- })
-
- expect(wrapper).toHaveText(message)
- })
-
- // test all notification levels
- notificationLevels.map((level) => {
- it(`should accept level prop of ${level}`, () => {
- const wrapper = renderComponent({
- level,
- message,
- })
- const wrapperProps = wrapper.props()
-
- expect(wrapperProps.level).toEqual(level)
- })
-
- return false
- })
-
- // test all notification usages
- VALID_USAGES.map((usage) => {
- it(`should render with usage prop of ${usage}`, () => {
- const wrapper = renderComponent({
- usage,
- message,
- })
- const wrapperProps = wrapper.props()
- expect(wrapperProps.usage).toEqual(usage)
- })
-
- return false
- })
-})
diff --git a/src/containers/shared/components/Transaction/AMMBid/test/AMMBid.test.tsx b/src/containers/shared/components/Transaction/AMMBid/test/AMMBidSimple.test.tsx
similarity index 63%
rename from src/containers/shared/components/Transaction/AMMBid/test/AMMBid.test.tsx
rename to src/containers/shared/components/Transaction/AMMBid/test/AMMBidSimple.test.tsx
index 3dd293355..8e41c419b 100644
--- a/src/containers/shared/components/Transaction/AMMBid/test/AMMBid.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMBid/test/AMMBidSimple.test.tsx
@@ -1,32 +1,34 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import bidMock from './mock_data/amm_bid.json'
-describe('AMM Bid Tests', () => {
- const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
+
+describe('AMM Bid: Simple', () => {
+ afterEach(cleanup)
it('renders from transaction', () => {
- const wrapper = createWrapper(bidMock)
+ renderComponent(bidMock)
expectSimpleRowText(
- wrapper,
+ screen,
'min_slot_price',
'100.00 LP.rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
expectSimpleRowText(
- wrapper,
+ screen,
'max_slot_price',
'500.00 LP.rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
expectSimpleRowText(
- wrapper,
+ screen,
'auth_accounts',
'ra8uHq2Qme5j19TqvPzTE2nqT12Zc3xJmKrU6o2YguZi847RaiH2QGTkL4eZWZjbxZvk',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AMMCreate/test/AMMCreate.test.tsx b/src/containers/shared/components/Transaction/AMMCreate/test/AMMCreate.test.tsx
index 6e08063a6..a762ec65f 100644
--- a/src/containers/shared/components/Transaction/AMMCreate/test/AMMCreate.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMCreate/test/AMMCreate.test.tsx
@@ -1,24 +1,26 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import createMock from './mock_data/amm_create.json'
+const renderComponent = createSimpleRenderFactory(Simple)
+
describe('AMM Create Tests', () => {
- const createWrapper = createSimpleWrapperFactory(Simple)
+ afterEach(cleanup)
it('renders from transaction', () => {
- const wrapper = createWrapper(createMock)
- expectSimpleRowText(wrapper, 'asset1', '\uE90010,000.00 XRP')
- expectSimpleRowText(wrapper, 'trading_fee', '0.001%')
+ renderComponent(createMock)
+ expectSimpleRowText(screen, 'asset1', '\uE90010,000.00 XRP')
+ expectSimpleRowText(screen, 'trading_fee', '0.001%')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$10,000.00 USD.rhpHaFggC92ELty3n3yDEtuFgWxXWkUFET',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteDescription.test.tsx b/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteDescription.test.tsx
index a3c04bebe..13bcaeac8 100644
--- a/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteDescription.test.tsx
@@ -1,22 +1,22 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import mockAMMDelete from './mock_data/AMMDelete.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('AMMDelete: Description', () => {
+ afterEach(cleanup)
it('renders description for AMMDelete transaction', () => {
- const wrapper = createWrapper(mockAMMDelete)
+ renderComponent(mockAMMDelete)
- expect(wrapper.find('[data-testid="amm-delete-description"]')).toHaveText(
+ expect(screen.getByTestId('amm-delete-description')).toHaveTextContent(
'Attempted to delete the AMM for \uE900 XRP and FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9.If there were more than 512 trustlines, this only removes 512 trustlines instead.',
)
- expect(wrapper.find('a')).toHaveProp(
+ expect(screen.queryByRole('link')).toHaveAttribute(
'href',
'/token/FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9',
)
-
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteSimple.test.tsx b/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteSimple.test.tsx
index b516be24a..f1fc2ae2d 100644
--- a/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteSimple.test.tsx
@@ -1,21 +1,22 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import { expectSimpleRowText } from '../../test'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockAMMDelete from './mock_data/AMMDelete.json'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('AMMDelete: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockAMMDelete) // TOOD: - Make this look up asset 1 / asset 2 currency codes
- expectSimpleRowText(wrapper, 'asset1', '\uE900 XRP')
+ renderComponent(mockAMMDelete) // TOOD: - Make this look up asset 1 / asset 2 currency codes
+ expectSimpleRowText(screen, 'asset1', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteTableDetail.test.tsx b/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteTableDetail.test.tsx
index 2d2b6ea70..2170bceb2 100644
--- a/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteTableDetail.test.tsx
@@ -1,20 +1,19 @@
+import { cleanup, screen } from '@testing-library/react'
import { TableDetail } from '../TableDetail'
import mockAMMDelete from './mock_data/AMMDelete.json'
-import { createTableDetailWrapperFactory } from '../../test'
+import { createTableDetailRenderFactory } from '../../test'
import i18n from '../../../../../../i18n/testConfigEnglish'
-const createWrapper = createTableDetailWrapperFactory(TableDetail, i18n)
+const renderComponent = createTableDetailRenderFactory(TableDetail, i18n)
describe('AMMDelete: TableDetail', () => {
+ afterEach(cleanup)
it('renders with an expiration and offer', () => {
- const wrapper = createWrapper(mockAMMDelete)
+ renderComponent(mockAMMDelete)
- expect(wrapper.find('[data-testid="asset"]')).toHaveText(
- 'Asset 1\uE900 XRP',
- )
- expect(wrapper.find('[data-testid="asset2"]')).toHaveText(
+ expect(screen.getByTestId('asset')).toHaveTextContent('Asset 1\uE900 XRP')
+ expect(screen.getByTestId('asset2')).toHaveTextContent(
'Asset 2FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AMMDeposit/test/AMMDeposit.test.tsx b/src/containers/shared/components/Transaction/AMMDeposit/test/AMMDeposit.test.tsx
index f90ddcbe2..7b07a2c6c 100644
--- a/src/containers/shared/components/Transaction/AMMDeposit/test/AMMDeposit.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMDeposit/test/AMMDeposit.test.tsx
@@ -1,6 +1,7 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import {
- createSimpleWrapperFactory,
+ createSimpleRenderFactory,
expectSimpleRowNotToExist,
expectSimpleRowText,
} from '../../test'
@@ -11,98 +12,94 @@ import depositEprice from './mock_data/deposit_eprice.json'
import depositNonXRP from './mock_data/deposit_nonxrp.json'
import depositFail from './mock_data/deposit_fail.json'
+const renderComponent = createSimpleRenderFactory(Simple)
+
describe('AMM Deposit Tests', () => {
- const createWrapper = createSimpleWrapperFactory(Simple)
+ afterEach(cleanup)
it('renders with both assets', () => {
- const wrapper = createWrapper(depositBothAssets)
- expectSimpleRowText(wrapper, 'asset1', '\uE90010,997.290462 XRP')
+ renderComponent(depositBothAssets)
+ expectSimpleRowText(screen, 'asset1', '\uE90010,997.290462 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$10,000.00 USD.rhpHaFggC92ELty3n3yDEtuFgWxXWkUFET',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
- wrapper.unmount()
})
it('renders only with USD', () => {
- const wrapper = createWrapper(depositUSD)
- expectSimpleRowNotToExist(wrapper, 'asset1')
+ renderComponent(depositUSD)
+ expectSimpleRowNotToExist(screen, 'asset1')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$2,000.00 USD.rhpHaFggC92ELty3n3yDEtuFgWxXWkUFET',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
- wrapper.unmount()
})
it('renders only with XRP', () => {
- const wrapper = createWrapper(depositXRP)
- expectSimpleRowText(wrapper, 'asset1', '\uE9001,000.00 XRP')
+ renderComponent(depositXRP)
+ expectSimpleRowText(screen, 'asset1', '\uE9001,000.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
- wrapper.unmount()
})
it('renders with eprice', () => {
- const wrapper = createWrapper(depositEprice)
- expectSimpleRowNotToExist(wrapper, 'asset1')
+ renderComponent(depositEprice)
+ expectSimpleRowNotToExist(screen, 'asset1')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$1,000.00 USD.rA3nNmhWKRZvcsA89DxTRbV62JiaSZWdy',
)
expectSimpleRowText(
- wrapper,
+ screen,
'effective_price',
'$0.10 USD.rA3nNmhWKRZvcsA89DxTRbV62JiaSZWdy',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rHrzrzVHSyunKzW3JLgSaLcsxfwVLPVV97',
)
- wrapper.unmount()
})
it('renders with both assets non XRP', () => {
- const wrapper = createWrapper(depositNonXRP)
+ renderComponent(depositNonXRP)
expectSimpleRowText(
- wrapper,
+ screen,
'asset1',
'€500.00 EUR.rEaiyQKvxYWmh7q9mvSm11kZmKx92HZdmr',
)
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$500.00 USD.rEaiyQKvxYWmh7q9mvSm11kZmKx92HZdmr',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rEJ1X5BoSmHqa5h6TSVvYrHAzFmyxGqNic',
)
- wrapper.unmount()
})
it('deposit shouldnt crash with tx that changes fee', () => {
- const wrapper = createWrapper(depositFail)
- expectSimpleRowNotToExist(wrapper, 'asset1')
- expectSimpleRowNotToExist(wrapper, 'asset2')
- expectSimpleRowNotToExist(wrapper, 'account_id')
- wrapper.unmount()
+ renderComponent(depositFail)
+ expectSimpleRowNotToExist(screen, 'asset1')
+ expectSimpleRowNotToExist(screen, 'asset2')
+ expectSimpleRowNotToExist(screen, 'account_id')
})
})
diff --git a/src/containers/shared/components/Transaction/AMMVote/test/AMMVote.test.tsx b/src/containers/shared/components/Transaction/AMMVote/test/AMMVote.test.tsx
index e9e9799a3..9d56c8dac 100644
--- a/src/containers/shared/components/Transaction/AMMVote/test/AMMVote.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMVote/test/AMMVote.test.tsx
@@ -1,18 +1,20 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import voteMock from './mock_data/amm_vote.json'
+const renderComponent = createSimpleRenderFactory(Simple)
+
describe('AMM Vote Tests', () => {
- const createWrapper = createSimpleWrapperFactory(Simple)
+ afterEach(cleanup)
it('renders from transaction', () => {
- const wrapper = createWrapper(voteMock)
- expectSimpleRowText(wrapper, 'trading_fee', '0.001%')
+ renderComponent(voteMock)
+ expectSimpleRowText(screen, 'trading_fee', '0.001%')
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AMMWithdraw/test/AMMWithdraw.test.tsx b/src/containers/shared/components/Transaction/AMMWithdraw/test/AMMWithdraw.test.tsx
index c086d1545..07ce37a25 100644
--- a/src/containers/shared/components/Transaction/AMMWithdraw/test/AMMWithdraw.test.tsx
+++ b/src/containers/shared/components/Transaction/AMMWithdraw/test/AMMWithdraw.test.tsx
@@ -1,6 +1,7 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import {
- createSimpleWrapperFactory,
+ createSimpleRenderFactory,
expectSimpleRowNotToExist,
expectSimpleRowText,
} from '../../test'
@@ -9,65 +10,63 @@ import withdrawUSDMock from './mock_data/withdraw_usd.json'
import withdrawXRPMock from './mock_data/withdraw_xrp.json'
import withdrawEpriceMock from './mock_data/withdraw_eprice.json'
+const renderComponent = createSimpleRenderFactory(Simple)
+
describe('AMM Withdraw Tests', () => {
- const createWrapper = createSimpleWrapperFactory(Simple)
+ afterEach(cleanup)
it('renders from transaction', () => {
- const wrapper = createWrapper(withdrawMock)
- expectSimpleRowText(wrapper, 'asset1', '\uE9003,666.580862 XRP')
+ renderComponent(withdrawMock)
+ expectSimpleRowText(screen, 'asset1', '\uE9003,666.580862 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$4,000.00 USD.rhpHaFggC92ELty3n3yDEtuFgWxXWkUFET',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rMEdVzU8mtEArzjrN9avm3kA675GX7ez8W',
)
- wrapper.unmount()
})
it('renders transaction from usd only', () => {
- const wrapper = createWrapper(withdrawUSDMock)
- expectSimpleRowNotToExist(wrapper, 'asset1')
+ renderComponent(withdrawUSDMock)
+ expectSimpleRowNotToExist(screen, 'asset1')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$100.00 USD.rA3nNmhWKRZvcsA89DxTRbV62JiaSZWdy',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rHrzrzVHSyunKzW3JLgSaLcsxfwVLPVV97',
)
- wrapper.unmount()
})
it('renders transaction from XRP only', () => {
- const wrapper = createWrapper(withdrawXRPMock)
- expectSimpleRowNotToExist(wrapper, 'asset2')
- expectSimpleRowText(wrapper, 'asset1', '\uE90099.99998 XRP')
+ renderComponent(withdrawXRPMock)
+ expectSimpleRowNotToExist(screen, 'asset2')
+ expectSimpleRowText(screen, 'asset1', '\uE90099.99998 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rHrzrzVHSyunKzW3JLgSaLcsxfwVLPVV97',
)
- wrapper.unmount()
})
it('renders transaction from eprice', () => {
- const wrapper = createWrapper(withdrawEpriceMock)
- expectSimpleRowNotToExist(wrapper, 'asset1')
+ renderComponent(withdrawEpriceMock)
+ expectSimpleRowNotToExist(screen, 'asset1')
expectSimpleRowText(
- wrapper,
+ screen,
'asset2',
'$1,639.41097028 USD.rA3nNmhWKRZvcsA89DxTRbV62JiaSZWdy',
)
expectSimpleRowText(
- wrapper,
+ screen,
'account_id',
'rHrzrzVHSyunKzW3JLgSaLcsxfwVLPVV97',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AccountDelete/test/AccountDeleteSimple.test.tsx b/src/containers/shared/components/Transaction/AccountDelete/test/AccountDeleteSimple.test.tsx
index 97a9c908f..68428c078 100644
--- a/src/containers/shared/components/Transaction/AccountDelete/test/AccountDeleteSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/AccountDelete/test/AccountDeleteSimple.test.tsx
@@ -1,28 +1,33 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockAccountDelete from './mock_data/AccountDelete.json'
import mockAccountDeleteWithDestinationTag from './mock_data/AccountDeleteWithDestinationTag.json'
+import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('AccountDelete: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockAccountDelete)
- expect(wrapper.find('.label')).toHaveText('destination')
- expect(wrapper.find('.value')).toHaveText(
+ renderComponent(mockAccountDelete)
+ expectSimpleRowLabel(screen, 'destination', 'destination')
+ expectSimpleRowText(
+ screen,
+ 'destination',
'raT74sdzpxJUaubcBAQNS8aLqFMU85Rr5J',
)
- wrapper.unmount()
})
it('renders with destination tag', () => {
- const wrapper = createWrapper(mockAccountDeleteWithDestinationTag)
- expect(wrapper.find('.label')).toHaveText('destination')
- expect(wrapper.find('.value')).toHaveText(
+ renderComponent(mockAccountDeleteWithDestinationTag)
+ expectSimpleRowLabel(screen, 'destination', 'destination')
+ expectSimpleRowText(
+ screen,
+ 'destination',
'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn:123123',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AccountSet/test/AccountSetDescription.test.tsx b/src/containers/shared/components/Transaction/AccountSet/test/AccountSetDescription.test.tsx
index 17c70de7c..4f0e3c5f7 100644
--- a/src/containers/shared/components/Transaction/AccountSet/test/AccountSetDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/AccountSet/test/AccountSetDescription.test.tsx
@@ -1,24 +1,27 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
import mockAccountSetWithDomain from './mock_data/AccountSetWithDomain.json'
import mockAccountSetWithClearFlag from './mock_data/AccountSetWithClearFlag.json'
import mockAccountSetWithSetFlag from './mock_data/AccountSetWithSetFlag.json'
import mockAccountSetWithMessageKey from './mock_data/AccountSetWithMessageKey.json'
import mockAccountSetWithNFTokenMinter from './mock_data/AccountSetWithNFTokenMinter.json'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('AccountSet: Description', () => {
+ afterEach(cleanup)
it('renders tx that sets the domain', () => {
- const wrapper = createWrapper(mockAccountSetWithDomain)
- expect(wrapper).toHaveText('It sets the account domain as mduo13.com')
- wrapper.unmount()
+ const { container } = renderComponent(mockAccountSetWithDomain)
+ expect(container).toHaveTextContent(
+ 'It sets the account domain as mduo13.com',
+ )
})
it('renders tx that sets the email hash', () => {
- const wrapper = createWrapper({
+ const { container } = renderComponent({
...mockAccountSetWithDomain,
tx: {
...mockAccountSetWithDomain.tx,
@@ -26,55 +29,52 @@ describe('AccountSet: Description', () => {
EmailHash: '7AC3878BF42A5329698F468A6AAA03B9',
},
})
- expect(wrapper).toHaveText(
+ expect(container).toHaveTextContent(
'It sets the account email hash as 7AC3878BF42A5329698F468A6AAA03B9',
)
- wrapper.unmount()
})
it('renders tx that clears a flag', () => {
- const wrapper = createWrapper(mockAccountSetWithClearFlag)
- expect(wrapper).toHaveText('It clears the account flag asfGlobalFreeze')
- wrapper.unmount()
+ const { container } = renderComponent(mockAccountSetWithClearFlag)
+ expect(container).toHaveTextContent(
+ 'It clears the account flag asfGlobalFreeze',
+ )
})
it('renders tx that sets a flag', () => {
- const wrapper = createWrapper(mockAccountSetWithSetFlag)
- expect(wrapper).toHaveText('It sets the account flag asfRequireDest')
- wrapper.unmount()
+ const { container } = renderComponent(mockAccountSetWithSetFlag)
+ expect(container).toHaveTextContent(
+ 'It sets the account flag asfRequireDest',
+ )
})
it('renders tx that clears a flag that is not defined', () => {
- const wrapper = createWrapper({
+ const { container } = renderComponent({
...mockAccountSetWithClearFlag,
tx: { ...mockAccountSetWithClearFlag.tx, ClearFlag: 45 },
})
- expect(wrapper).toHaveText('It clears the account flag 45')
- wrapper.unmount()
+ expect(container).toHaveTextContent('It clears the account flag 45')
})
it('renders tx that sets a flag that is not defined', () => {
- const wrapper = createWrapper({
+ const { container } = renderComponent({
...mockAccountSetWithSetFlag,
tx: { ...mockAccountSetWithSetFlag.tx, SetFlag: 45 },
})
- expect(wrapper).toHaveText('It sets the account flag 45')
- wrapper.unmount()
+ expect(container).toHaveTextContent('It sets the account flag 45')
})
it('renders tx that sets a message', () => {
- const wrapper = createWrapper(mockAccountSetWithMessageKey)
- expect(wrapper.find('[data-testid="message-key"]')).toHaveText(
+ renderComponent(mockAccountSetWithMessageKey)
+ expect(screen.getByTestId('message-key')).toHaveTextContent(
'It sets the account message key as 020000000000000000000000000941C216565D33C8A8ACD1A33C359E84D652D1DA',
)
- wrapper.unmount()
})
it('renders tx that sets a minter', () => {
- const wrapper = createWrapper(mockAccountSetWithNFTokenMinter)
- expect(wrapper.find('[data-testid="minter"]')).toHaveText(
+ renderComponent(mockAccountSetWithNFTokenMinter)
+ expect(screen.getByTestId('minter')).toHaveTextContent(
'It sets rXMART8usFd5kABXCayoP6ZfB35b4v43t as the authorized minter for this account',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/AccountSet/test/AccountSetSimple.test.tsx b/src/containers/shared/components/Transaction/AccountSet/test/AccountSetSimple.test.tsx
index 628b1c77e..90a26d26a 100644
--- a/src/containers/shared/components/Transaction/AccountSet/test/AccountSetSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/AccountSet/test/AccountSetSimple.test.tsx
@@ -1,6 +1,7 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockAccountSetWithDomain from './mock_data/AccountSetWithDomain.json'
import mockAccountSetWithClearFlag from './mock_data/AccountSetWithClearFlag.json'
@@ -9,18 +10,18 @@ import mockAccountSetWithMessageKey from './mock_data/AccountSetWithMessageKey.j
import mockAccountSetWithNFTokenMinter from './mock_data/AccountSetWithNFTokenMinter.json'
import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('AccountSet: Simple', () => {
+ afterEach(cleanup)
it('renders tx that sets the domain', () => {
- const wrapper = createWrapper(mockAccountSetWithDomain)
- expectSimpleRowLabel(wrapper, 'domain', 'domain')
- expectSimpleRowText(wrapper, 'domain', 'mduo13.com')
- wrapper.unmount()
+ renderComponent(mockAccountSetWithDomain)
+ expectSimpleRowLabel(screen, 'domain', 'domain')
+ expectSimpleRowText(screen, 'domain', 'mduo13.com')
})
it('renders tx that sets the email hash', () => {
- const wrapper = createWrapper({
+ renderComponent({
...mockAccountSetWithDomain,
tx: {
...mockAccountSetWithDomain.tx,
@@ -29,59 +30,53 @@ describe('AccountSet: Simple', () => {
},
})
- expectSimpleRowLabel(wrapper, 'email', 'email hash')
- expectSimpleRowText(wrapper, 'email', '7AC3878BF42A5329698F468A6AAA03B9')
+ expectSimpleRowLabel(screen, 'email', 'email hash')
+ expectSimpleRowText(screen, 'email', '7AC3878BF42A5329698F468A6AAA03B9')
})
it('renders tx that clears a flag', () => {
- const wrapper = createWrapper(mockAccountSetWithClearFlag)
- expectSimpleRowLabel(wrapper, 'clear-flag', 'clear flag')
- expectSimpleRowText(wrapper, 'clear-flag', 'asfGlobalFreeze')
- wrapper.unmount()
+ renderComponent(mockAccountSetWithClearFlag)
+ expectSimpleRowLabel(screen, 'clear-flag', 'clear flag')
+ expectSimpleRowText(screen, 'clear-flag', 'asfGlobalFreeze')
})
it('renders tx that sets a flag', () => {
- const wrapper = createWrapper(mockAccountSetWithSetFlag)
- expectSimpleRowLabel(wrapper, 'set-flag', 'set flag')
- expectSimpleRowText(wrapper, 'set-flag', 'asfRequireDest')
- wrapper.unmount()
+ renderComponent(mockAccountSetWithSetFlag)
+ expectSimpleRowLabel(screen, 'set-flag', 'set flag')
+ expectSimpleRowText(screen, 'set-flag', 'asfRequireDest')
})
it('renders tx that clears a flag without a defined flag', () => {
- const wrapper = createWrapper({
+ renderComponent({
...mockAccountSetWithClearFlag,
tx: { ...mockAccountSetWithClearFlag.tx, ClearFlag: 45 },
})
- expectSimpleRowLabel(wrapper, 'clear-flag', 'clear flag')
- expectSimpleRowText(wrapper, 'clear-flag', '45')
- wrapper.unmount()
+ expectSimpleRowLabel(screen, 'clear-flag', 'clear flag')
+ expectSimpleRowText(screen, 'clear-flag', '45')
})
it('renders tx that sets a flag without a defined flag', () => {
- const wrapper = createWrapper({
+ renderComponent({
...mockAccountSetWithSetFlag,
tx: { ...mockAccountSetWithSetFlag.tx, SetFlag: 45 },
})
- expectSimpleRowLabel(wrapper, 'set-flag', 'set flag')
- expectSimpleRowText(wrapper, 'set-flag', '45')
- wrapper.unmount()
+ expectSimpleRowLabel(screen, 'set-flag', 'set flag')
+ expectSimpleRowText(screen, 'set-flag', '45')
})
it('renders tx that sets a message', () => {
- const wrapper = createWrapper(mockAccountSetWithMessageKey)
- expectSimpleRowLabel(wrapper, 'message', 'message key')
+ renderComponent(mockAccountSetWithMessageKey)
+ expectSimpleRowLabel(screen, 'message', 'message key')
expectSimpleRowText(
- wrapper,
+ screen,
'message',
'020000000000000000000000000941C216565D33C8A8ACD1A33C359E84D652D1DA',
)
- wrapper.unmount()
})
it('renders tx that sets a minter', () => {
- const wrapper = createWrapper(mockAccountSetWithNFTokenMinter)
- expectSimpleRowLabel(wrapper, 'minter', 'NFT Minter')
- expectSimpleRowText(wrapper, 'minter', 'rXMART8usFd5kABXCayoP6ZfB35b4v43t')
- wrapper.unmount()
+ renderComponent(mockAccountSetWithNFTokenMinter)
+ expectSimpleRowLabel(screen, 'minter', 'NFT Minter')
+ expectSimpleRowText(screen, 'minter', 'rXMART8usFd5kABXCayoP6ZfB35b4v43t')
})
})
diff --git a/src/containers/shared/components/Transaction/AccountSet/test/AccountSetTableDetail.test.tsx b/src/containers/shared/components/Transaction/AccountSet/test/AccountSetTableDetail.test.tsx
index dbc1527ff..b471b35e3 100644
--- a/src/containers/shared/components/Transaction/AccountSet/test/AccountSetTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/AccountSet/test/AccountSetTableDetail.test.tsx
@@ -1,4 +1,5 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import i18n from '../../../../../../i18n/testConfigEnglish'
import { TableDetail } from '../TableDetail'
@@ -8,17 +9,17 @@ import mockAccountSetWithSetFlag from './mock_data/AccountSetWithSetFlag.json'
import mockAccountSetWithMessageKey from './mock_data/AccountSetWithMessageKey.json'
import mockAccountSetWithNFTokenMinter from './mock_data/AccountSetWithNFTokenMinter.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail, i18n)
+const renderComponent = createTableDetailRenderFactory(TableDetail, i18n)
describe('AccountSet: TableDetail', () => {
+ afterEach(cleanup)
it('renders tx that sets the domain', () => {
- const wrapper = createWrapper(mockAccountSetWithDomain)
- expect(wrapper).toHaveText('domain: mduo13.com')
- wrapper.unmount()
+ const { container } = renderComponent(mockAccountSetWithDomain)
+ expect(container).toHaveTextContent('domain: mduo13.com')
})
it('renders tx that sets the email hash', () => {
- const wrapper = createWrapper({
+ const { container } = renderComponent({
...mockAccountSetWithDomain,
tx: {
...mockAccountSetWithDomain.tx,
@@ -26,53 +27,48 @@ describe('AccountSet: TableDetail', () => {
EmailHash: '7AC3878BF42A5329698F468A6AAA03B9',
},
})
- expect(wrapper).toHaveText('email hash: 7AC3878BF42A5329698F468A6AAA03B9')
- wrapper.unmount()
+ expect(container).toHaveTextContent(
+ 'email hash: 7AC3878BF42A5329698F468A6AAA03B9',
+ )
})
it('renders tx that clears a flag', () => {
- const wrapper = createWrapper(mockAccountSetWithClearFlag)
- expect(wrapper).toHaveText('clear flag: asfGlobalFreeze')
- wrapper.unmount()
+ const { container } = renderComponent(mockAccountSetWithClearFlag)
+ expect(container).toHaveTextContent('clear flag: asfGlobalFreeze')
})
it('renders tx that sets a flag', () => {
- const wrapper = createWrapper(mockAccountSetWithSetFlag)
- expect(wrapper).toHaveText('set flag: asfRequireDest')
- wrapper.unmount()
+ const { container } = renderComponent(mockAccountSetWithSetFlag)
+ expect(container).toHaveTextContent('set flag: asfRequireDest')
})
it('renders tx that clears a flag that is not defined', () => {
- const wrapper = createWrapper({
+ const { container } = renderComponent({
...mockAccountSetWithClearFlag,
tx: { ...mockAccountSetWithClearFlag.tx, ClearFlag: 45 },
})
- expect(wrapper).toHaveText('clear flag: 45')
- wrapper.unmount()
+ expect(container).toHaveTextContent('clear flag: 45')
})
it('renders tx that sets a flag that is not defined', () => {
- const wrapper = createWrapper({
+ const { container } = renderComponent({
...mockAccountSetWithSetFlag,
tx: { ...mockAccountSetWithSetFlag.tx, SetFlag: 45 },
})
- expect(wrapper).toHaveText('set flag: 45')
- wrapper.unmount()
+ expect(container).toHaveTextContent('set flag: 45')
})
it('renders tx that sets a message', () => {
- const wrapper = createWrapper(mockAccountSetWithMessageKey)
- expect(wrapper).toHaveText(
+ const { container } = renderComponent(mockAccountSetWithMessageKey)
+ expect(container).toHaveTextContent(
'message key: 020000000000000000000000000941C216565D33C8A8ACD1A33C359E84D652D1DA',
)
- wrapper.unmount()
})
it('renders tx that sets a minter', () => {
- const wrapper = createWrapper(mockAccountSetWithNFTokenMinter)
- expect(wrapper.find('[data-testid="minter"]')).toHaveText(
+ renderComponent(mockAccountSetWithNFTokenMinter)
+ expect(screen.getByTestId('minter')).toHaveTextContent(
'NFT Minter: rXMART8usFd5kABXCayoP6ZfB35b4v43t',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/Clawback/Simple.tsx b/src/containers/shared/components/Transaction/Clawback/Simple.tsx
index df1ab8a61..e3cc100b1 100644
--- a/src/containers/shared/components/Transaction/Clawback/Simple.tsx
+++ b/src/containers/shared/components/Transaction/Clawback/Simple.tsx
@@ -19,7 +19,7 @@ export const Simple: TransactionSimpleComponent = ({
)}
{amount && (
-
+
)}
diff --git a/src/containers/shared/components/Transaction/Clawback/TableDetail.tsx b/src/containers/shared/components/Transaction/Clawback/TableDetail.tsx
index 0811fe42c..18f8b5a73 100644
--- a/src/containers/shared/components/Transaction/Clawback/TableDetail.tsx
+++ b/src/containers/shared/components/Transaction/Clawback/TableDetail.tsx
@@ -13,7 +13,7 @@ export const TableDetail = ({
return (
{amount && holder && (
-
+
{t('claws_back')}
diff --git a/src/containers/shared/components/Transaction/Clawback/test/ClawbackDescription.test.tsx b/src/containers/shared/components/Transaction/Clawback/test/ClawbackDescription.test.tsx
index 2bd59f9ff..34a4a4c2b 100644
--- a/src/containers/shared/components/Transaction/Clawback/test/ClawbackDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/Clawback/test/ClawbackDescription.test.tsx
@@ -1,19 +1,20 @@
-import { createDescriptionWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createDescriptionRenderFactory } from '../../test'
import { Description } from '../Description'
import transaction from './mock_data/Clawback.json'
import i18n from '../../../../../../i18n/testConfigEnglish'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
-describe('Clawback', () => {
+describe('Clawback - Description', () => {
+ afterEach(cleanup)
it('handles Clawback Description ', () => {
- const wrapper = createWrapper(transaction)
- expect(wrapper.find('[data-testid="from-to-line"]')).toHaveText(
+ renderComponent(transaction)
+ expect(screen.getByTestId('from-to-line')).toHaveTextContent(
`rDZ713igKfedN4hhY6SjQse4Mv3ZrBxnn9 claws back from rscBWQpyZEmQvupeB1quu7Ky8YX4f5CHDP`,
)
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`The max clawback amount is 4,840.00 FOO.rDZ713igKfedN4hhY6SjQse4Mv3ZrBxnn9`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/Clawback/test/ClawbackSimple.test.tsx b/src/containers/shared/components/Transaction/Clawback/test/ClawbackSimple.test.tsx
index 1a7e19ee7..9398126cc 100644
--- a/src/containers/shared/components/Transaction/Clawback/test/ClawbackSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/Clawback/test/ClawbackSimple.test.tsx
@@ -1,5 +1,6 @@
import { useQuery } from 'react-query'
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import transaction from './mock_data/Clawback.json'
import transactionFailure from './mock_data/Clawback_Failure.json'
@@ -11,18 +12,18 @@ jest.mock('react-query', () => ({
useQuery: jest.fn(),
}))
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('Clawback', () => {
+describe('Clawback: Simple', () => {
+ afterEach(cleanup)
it('handles Clawback simple view ', () => {
- const wrapper = createWrapper(transaction)
- expectSimpleRowText(wrapper, 'holder', 'rscBWQpyZEmQvupeB1quu7Ky8YX4f5CHDP')
+ renderComponent(transaction)
+ expectSimpleRowText(screen, 'holder', 'rscBWQpyZEmQvupeB1quu7Ky8YX4f5CHDP')
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'clawback-amount',
'3,840.00 FOO.rDZ713igKfedN4hhY6SjQse4Mv3ZrBxnn9',
)
- wrapper.unmount()
})
it('handles MPT Clawback simple view ', () => {
@@ -34,26 +35,23 @@ describe('Clawback', () => {
useQuery.mockImplementation(() => ({
data,
}))
- const wrapper = createWrapper(transactionMPT)
- expectSimpleRowText(wrapper, 'holder', 'rUZTPFN7MBJkjiZ48rak6q7MbhT4ur2kAD')
+ renderComponent(transactionMPT)
+ expectSimpleRowText(screen, 'holder', 'rUZTPFN7MBJkjiZ48rak6q7MbhT4ur2kAD')
expectSimpleRowText(
- wrapper,
+ screen,
'amount',
'0.05 MPT (00000D668E702F54A27C42EF98C13B0787D1766CC9162A47)',
)
-
- wrapper.unmount()
})
it('handles failed Clawback simple view ', () => {
- const wrapper = createWrapper(transactionFailure)
- expectSimpleRowText(wrapper, 'holder', 'rDZ713igKfedN4hhY6SjQse4Mv3ZrBxnn9')
+ renderComponent(transactionFailure)
+ expectSimpleRowText(screen, 'holder', 'rDZ713igKfedN4hhY6SjQse4Mv3ZrBxnn9')
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'clawback-amount',
'4,840.00 FOO.rscBWQpyZEmQvupeB1quu7Ky8YX4f5CHDP',
)
- wrapper.unmount()
})
it('handles failed MPT Clawback simple view ', () => {
@@ -65,14 +63,13 @@ describe('Clawback', () => {
useQuery.mockImplementation(() => ({
data,
}))
- const wrapper = createWrapper(transactionMPTFailure)
+ renderComponent(transactionMPTFailure)
- expectSimpleRowText(wrapper, 'holder', 'r9rAqX8Jjo4uACsimYDVsy5thHDPivujqf')
+ expectSimpleRowText(screen, 'holder', 'r9rAqX8Jjo4uACsimYDVsy5thHDPivujqf')
expectSimpleRowText(
- wrapper,
+ screen,
'amount',
'0.05 MPT (000010952ECE2AFC727F1C67EF568F360A2D92CB7C29FF7C)',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/Clawback/test/ClawbackTableDetail.test.tsx b/src/containers/shared/components/Transaction/Clawback/test/ClawbackTableDetail.test.tsx
index 0fd2926e5..770dd7f0a 100644
--- a/src/containers/shared/components/Transaction/Clawback/test/ClawbackTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/Clawback/test/ClawbackTableDetail.test.tsx
@@ -1,15 +1,16 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import transaction from './mock_data/Clawback.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
-describe('Clawback', () => {
+describe('Clawback - TableDetail', () => {
+ afterEach(cleanup)
it('handles Clawback TableDetail ', () => {
- const wrapper = createWrapper(transaction)
- expect(wrapper.find('.clawback')).toHaveText(
+ renderComponent(transaction)
+ expect(screen.getByTestId('clawback')).toHaveTextContent(
`claws_back3,840.00 FOO.rDZ713igKfedN4hhY6SjQse4Mv3ZrBxnn9fromrscBWQpyZEmQvupeB1quu7Ky8YX4f5CHDP`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/DIDDelete/test/DIDDeleteSimple.test.tsx b/src/containers/shared/components/Transaction/DIDDelete/test/DIDDeleteSimple.test.tsx
index 6b81a49a5..f7936a246 100644
--- a/src/containers/shared/components/Transaction/DIDDelete/test/DIDDeleteSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/DIDDelete/test/DIDDeleteSimple.test.tsx
@@ -1,12 +1,13 @@
-import { createSimpleWrapperFactory } from '../../test'
+import { cleanup } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test'
import { Simple } from '../Simple'
import DIDDelete from './mock_data/DIDDelete.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('DIDDelete: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(DIDDelete)
- wrapper.unmount()
+ renderComponent(DIDDelete)
})
})
diff --git a/src/containers/shared/components/Transaction/DIDSet/test/DIDSetSimple.test.tsx b/src/containers/shared/components/Transaction/DIDSet/test/DIDSetSimple.test.tsx
index 433d2a4ed..72fa55215 100644
--- a/src/containers/shared/components/Transaction/DIDSet/test/DIDSetSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/DIDSet/test/DIDSetSimple.test.tsx
@@ -1,15 +1,16 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import DIDSet from './mock_data/DIDSet.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('DIDSet: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(DIDSet)
- expectSimpleRowText(wrapper, 'uri', 'did_example')
- expectSimpleRowText(wrapper, 'did-document', 'doc')
- expectSimpleRowText(wrapper, 'attestation', 'attest')
- wrapper.unmount()
+ renderComponent(DIDSet)
+ expectSimpleRowText(screen, 'uri', 'did_example')
+ expectSimpleRowText(screen, 'did-document', 'doc')
+ expectSimpleRowText(screen, 'attestation', 'attest')
})
})
diff --git a/src/containers/shared/components/Transaction/DIDSet/test/DIDSetTableDetail.test.tsx b/src/containers/shared/components/Transaction/DIDSet/test/DIDSetTableDetail.test.tsx
index 8a0af72fd..8b2ae6b1b 100644
--- a/src/containers/shared/components/Transaction/DIDSet/test/DIDSetTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/DIDSet/test/DIDSetTableDetail.test.tsx
@@ -1,14 +1,17 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import DIDSet from './mock_data/DIDSet.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('DIDSet: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(DIDSet)
- // eslint-disable-next-line no-useless-concat -- easier to read this way
- expect(wrapper).toHaveText('uri: did_example' + 'did_document: doc')
- wrapper.unmount()
+ const { container } = renderComponent(DIDSet)
+ expect(container).toHaveTextContent(
+ // eslint-disable-next-line no-useless-concat -- easier to read this way
+ 'uri: did_example' + 'did_document: doc',
+ )
})
})
diff --git a/src/containers/shared/components/Transaction/DepositPreauth/Description.tsx b/src/containers/shared/components/Transaction/DepositPreauth/Description.tsx
index e722ba14c..46229795a 100644
--- a/src/containers/shared/components/Transaction/DepositPreauth/Description.tsx
+++ b/src/containers/shared/components/Transaction/DepositPreauth/Description.tsx
@@ -8,7 +8,7 @@ export const Description = ({
}: TransactionDescriptionProps) => {
const { tx } = data
return tx.Authorize ? (
-
+
It Authorizes
@@ -16,7 +16,7 @@ export const Description = ({
) : (
-
+
It removes the authorization for
diff --git a/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthDescription.test.tsx b/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthDescription.test.tsx
index fdaa7079e..e57d0b23f 100644
--- a/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthDescription.test.tsx
@@ -1,27 +1,34 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import mockDepositPreaut from './mock_data/DepositPreauth.json'
+import mockDepositPreauth from './mock_data/DepositPreauth.json'
import mockDepositPreauthUnauthorize from './mock_data/DepositPreauthUnauthorize.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('DepositPreauth: Description', () => {
+ afterEach(cleanup)
it('renders description for authorize', () => {
- const wrapper = createWrapper(mockDepositPreaut)
- expect(wrapper.html()).toBe(
- ``,
+ renderComponent(mockDepositPreauth)
+ expect(screen.getByTestId('deposit-auth')).toHaveTextContent(
+ 'It authorizes rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM to send payments to this account',
)
- wrapper.unmount()
+ expect(
+ screen.getByText('rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM'),
+ ).toHaveAttribute('href')
})
it('renders description for unauthorize', () => {
- const wrapper = createWrapper(mockDepositPreauthUnauthorize)
- expect(wrapper.html()).toBe(
- ``,
+ renderComponent(mockDepositPreauthUnauthorize)
+
+ expect(screen.getByTestId('deposit-unauth')).toHaveTextContent(
+ 'It removes the authorization for rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM to send payments to this account',
)
- wrapper.unmount()
+ expect(
+ screen.getByText('rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM'),
+ ).toHaveAttribute('href')
})
})
diff --git a/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthSimple.test.tsx b/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthSimple.test.tsx
index 3793f16d2..e297636c2 100644
--- a/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/DepositPreauth/test/DepositPreauthSimple.test.tsx
@@ -1,28 +1,33 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockDepositPreauth from './mock_data/DepositPreauth.json'
import mockDepositPreauthUnauthorize from './mock_data/DepositPreauthUnauthorize.json'
+import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('DepositPreauth: Simple', () => {
+ afterEach(cleanup)
it('renders authorized', () => {
- const wrapper = createWrapper(mockDepositPreauth)
- expect(wrapper.find('.label')).toHaveText('authorize')
- expect(wrapper.find('.value')).toHaveText(
+ renderComponent(mockDepositPreauth)
+ expectSimpleRowLabel(screen, 'authorize', 'authorize')
+ expectSimpleRowText(
+ screen,
+ 'authorize',
'rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM',
)
- wrapper.unmount()
})
it('renders unauthorized', () => {
- const wrapper = createWrapper(mockDepositPreauthUnauthorize)
- expect(wrapper.find('.label')).toHaveText('unauthorize')
- expect(wrapper.find('.value')).toHaveText(
+ renderComponent(mockDepositPreauthUnauthorize)
+ expectSimpleRowLabel(screen, 'unauthorize', 'unauthorize')
+ expectSimpleRowText(
+ screen,
+ 'unauthorize',
'rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EnableAmendment/test/EnableAmendmentSimple.test.tsx b/src/containers/shared/components/Transaction/EnableAmendment/test/EnableAmendmentSimple.test.tsx
index a39951432..bb36a9a34 100644
--- a/src/containers/shared/components/Transaction/EnableAmendment/test/EnableAmendmentSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/EnableAmendment/test/EnableAmendmentSimple.test.tsx
@@ -1,6 +1,7 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockEnableAmendmentWithEnabled from './mock_data/EnableAmendmentWithEnabled.json'
@@ -12,7 +13,7 @@ import { getRippledVersion } from '../../../../amendmentUtils'
import { flushPromises } from '../../../../../test/utils'
import { getFeature } from '../../../../../../rippled/lib/rippled'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
jest.mock('../../../../amendmentUtils', () => {
// Require the original module to not be mocked...
@@ -45,28 +46,26 @@ const mockedGetFeature = getFeature as jest.MockedFunction
describe('EnableAmendment: Simple', () => {
afterEach(() => {
mockedGetFeature.mockReset()
+ cleanup()
})
it('renders tx that causes an amendment to loose majority', async () => {
mockedGetRippledVersion.mockImplementation(() => Promise.resolve('v1.9.1'))
mockedGetFeature.mockImplementation(() =>
Promise.resolve(mockFeatureExpandedSignerList),
)
- const wrapper = createWrapper(mockEnableAmendmentWithMinority)
- expectSimpleRowLabel(wrapper, 'name', 'Amendment Name')
- expectSimpleRowText(wrapper, 'name', 'Loading')
- expectSimpleRowLabel(wrapper, 'status', 'Amendment Status')
- expectSimpleRowText(wrapper, 'status', 'Lost Majority')
- expectSimpleRowLabel(wrapper, 'version', 'Introduced In')
- expectSimpleRowText(wrapper, 'version', 'Loading')
- expect(wrapper.find('[data-testid="date"]')).not.toExist()
+ renderComponent(mockEnableAmendmentWithMinority)
+ expectSimpleRowLabel(screen, 'name', 'Amendment Name')
+ expectSimpleRowText(screen, 'name', 'Loading')
+ expectSimpleRowLabel(screen, 'status', 'Amendment Status')
+ expectSimpleRowText(screen, 'status', 'Lost Majority')
+ expectSimpleRowLabel(screen, 'version', 'Introduced In')
+ expectSimpleRowText(screen, 'version', 'Loading')
+ expect(screen.queryByTestId('date')).toBeNull()
await flushPromises()
- wrapper.update()
- expectSimpleRowText(wrapper, 'name', 'ExpandedSignerList')
- expectSimpleRowText(wrapper, 'version', 'v1.9.1')
-
- wrapper.unmount()
+ expectSimpleRowText(screen, 'name', 'ExpandedSignerList')
+ expectSimpleRowText(screen, 'version', 'v1.9.1')
})
it('renders tx that causes an amendment to gain majority', async () => {
@@ -74,27 +73,24 @@ describe('EnableAmendment: Simple', () => {
mockedGetFeature.mockImplementation(() =>
Promise.resolve(mockFeatureExpandedSignerList),
)
- const wrapper = createWrapper(mockEnableAmendmentWithMajority)
- expectSimpleRowLabel(wrapper, 'name', 'Amendment Name')
- expectSimpleRowText(wrapper, 'name', 'Loading')
- expectSimpleRowLabel(wrapper, 'status', 'Amendment Status')
- expectSimpleRowText(wrapper, 'status', 'Got Majority')
- expectSimpleRowLabel(wrapper, 'version', 'Introduced In')
- expectSimpleRowText(wrapper, 'version', 'Loading')
- expectSimpleRowLabel(wrapper, 'date', 'Expected Date')
- expectSimpleRowText(wrapper, 'date', '10/13/2022, 3:28:31 PM')
+ renderComponent(mockEnableAmendmentWithMajority)
+ expectSimpleRowLabel(screen, 'name', 'Amendment Name')
+ expectSimpleRowText(screen, 'name', 'Loading')
+ expectSimpleRowLabel(screen, 'status', 'Amendment Status')
+ expectSimpleRowText(screen, 'status', 'Got Majority')
+ expectSimpleRowLabel(screen, 'version', 'Introduced In')
+ expectSimpleRowText(screen, 'version', 'Loading')
+ expectSimpleRowLabel(screen, 'date', 'Expected Date')
+ expectSimpleRowText(screen, 'date', '10/13/2022, 3:28:31 PM')
await flushPromises()
- wrapper.update()
- expectSimpleRowText(wrapper, 'name', 'ExpandedSignerList')
- expectSimpleRowText(wrapper, 'version', 'v1.9.1')
- expect(wrapper.find('[data-testid="name"] .value a')).toHaveProp(
+ expectSimpleRowText(screen, 'name', 'ExpandedSignerList')
+ expectSimpleRowText(screen, 'version', 'v1.9.1')
+ expect(screen.getByText('ExpandedSignerList')).toHaveAttribute(
'href',
'/amendment/B2A4DB846F0891BF2C76AB2F2ACC8F5B4EC64437135C6E56F3F859DE5FFD5856',
)
-
- wrapper.unmount()
})
it('renders tx that enables an amendment', async () => {
@@ -102,37 +98,33 @@ describe('EnableAmendment: Simple', () => {
mockedGetFeature.mockImplementation(() =>
Promise.resolve(mockFeatureNegativeUNL),
)
- const wrapper = createWrapper(mockEnableAmendmentWithEnabled)
- expectSimpleRowLabel(wrapper, 'name', 'Amendment Name')
- expectSimpleRowText(wrapper, 'name', 'Loading')
- expectSimpleRowLabel(wrapper, 'status', 'Amendment Status')
- expectSimpleRowText(wrapper, 'status', 'Enabled')
- expectSimpleRowLabel(wrapper, 'version', 'Introduced In')
- expectSimpleRowText(wrapper, 'version', 'Loading')
+ renderComponent(mockEnableAmendmentWithEnabled)
+ expectSimpleRowLabel(screen, 'name', 'Amendment Name')
+ expectSimpleRowText(screen, 'name', 'Loading')
+ expectSimpleRowLabel(screen, 'status', 'Amendment Status')
+ expectSimpleRowText(screen, 'status', 'Enabled')
+ expectSimpleRowLabel(screen, 'version', 'Introduced In')
+ expectSimpleRowText(screen, 'version', 'Loading')
await flushPromises()
- wrapper.update()
-
- expectSimpleRowText(wrapper, 'name', 'NegativeUNL')
- expectSimpleRowText(wrapper, 'version', 'v1.7.3')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'name', 'NegativeUNL')
+ expectSimpleRowText(screen, 'version', 'v1.7.3')
})
it('renders tx that cannot determine version or name', async () => {
mockedGetRippledVersion.mockImplementation(() => Promise.resolve(''))
mockedGetFeature.mockImplementation(() => Promise.resolve(null))
- const wrapper = createWrapper(mockEnableAmendmentWithEnabled)
- expectSimpleRowLabel(wrapper, 'name', 'Amendment Name')
- expectSimpleRowText(wrapper, 'name', 'Loading')
- expectSimpleRowLabel(wrapper, 'version', 'Introduced In')
- expectSimpleRowText(wrapper, 'version', 'Loading')
+ renderComponent(mockEnableAmendmentWithEnabled)
+ expectSimpleRowLabel(screen, 'name', 'Amendment Name')
+ expectSimpleRowText(screen, 'name', 'Loading')
+ expectSimpleRowLabel(screen, 'version', 'Introduced In')
+ expectSimpleRowText(screen, 'version', 'Loading')
await flushPromises()
- wrapper.update()
- expectSimpleRowText(wrapper, 'name', 'Unknown')
- expectSimpleRowText(wrapper, 'version', 'Unknown')
+ expectSimpleRowText(screen, 'name', 'Unknown')
+ expectSimpleRowText(screen, 'version', 'Unknown')
})
it('renders tx that cannot determine version', async () => {
@@ -140,32 +132,30 @@ describe('EnableAmendment: Simple', () => {
mockedGetFeature.mockImplementation(() =>
Promise.resolve(mockFeatureNegativeUNL),
)
- const wrapper = createWrapper(mockEnableAmendmentWithEnabled)
- expectSimpleRowLabel(wrapper, 'name', 'Amendment Name')
- expectSimpleRowText(wrapper, 'name', 'Loading')
- expectSimpleRowLabel(wrapper, 'version', 'Introduced In')
- expectSimpleRowText(wrapper, 'version', 'Loading')
+ renderComponent(mockEnableAmendmentWithEnabled)
+ expectSimpleRowLabel(screen, 'name', 'Amendment Name')
+ expectSimpleRowText(screen, 'name', 'Loading')
+ expectSimpleRowLabel(screen, 'version', 'Introduced In')
+ expectSimpleRowText(screen, 'version', 'Loading')
await flushPromises()
- wrapper.update()
- expectSimpleRowText(wrapper, 'name', 'NegativeUNL')
- expectSimpleRowText(wrapper, 'version', 'Unknown')
+ expectSimpleRowText(screen, 'name', 'NegativeUNL')
+ expectSimpleRowText(screen, 'version', 'Unknown')
})
it('renders tx that cannot determine name', async () => {
mockedGetRippledVersion.mockImplementation(() => Promise.resolve('v1.7.3'))
mockedGetFeature.mockImplementation(() => Promise.resolve(null))
- const wrapper = createWrapper(mockEnableAmendmentWithEnabled)
- expectSimpleRowLabel(wrapper, 'name', 'Amendment Name')
- expectSimpleRowText(wrapper, 'name', 'Loading')
- expectSimpleRowLabel(wrapper, 'version', 'Introduced In')
- expectSimpleRowText(wrapper, 'version', 'Loading')
+ renderComponent(mockEnableAmendmentWithEnabled)
+ expectSimpleRowLabel(screen, 'name', 'Amendment Name')
+ expectSimpleRowText(screen, 'name', 'Loading')
+ expectSimpleRowLabel(screen, 'version', 'Introduced In')
+ expectSimpleRowText(screen, 'version', 'Loading')
await flushPromises()
- wrapper.update()
- expectSimpleRowText(wrapper, 'name', 'Unknown')
- expectSimpleRowText(wrapper, 'version', 'v1.7.3')
+ expectSimpleRowText(screen, 'name', 'Unknown')
+ expectSimpleRowText(screen, 'version', 'v1.7.3')
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelDescription.test.tsx b/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelDescription.test.tsx
index 25af99edc..3359f3506 100644
--- a/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelDescription.test.tsx
@@ -1,15 +1,16 @@
+import { cleanup } from '@testing-library/react'
import EscrowCancel from './mock_data/EscrowCancel.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description)
+const renderComponent = createDescriptionRenderFactory(Description)
-describe('EscrowCancelDescription', () => {
+describe('EscrowCancel - Description', () => {
+ afterEach(cleanup)
it('renders description for EscrowCancel', () => {
- const wrapper = createWrapper(EscrowCancel)
- expect(wrapper.html()).toBe(
+ const { container } = renderComponent(EscrowCancel)
+ expect(container.innerHTML).toBe(
'The escrow was created byrpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56with transactionA979AD...',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelSimple.test.tsx b/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelSimple.test.tsx
index 9865b6169..5fdf3c4f3 100644
--- a/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelSimple.test.tsx
@@ -1,21 +1,22 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockEscrowCancel from './mock_data/EscrowCancel.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('EscrowCancelSimple', () => {
+describe('EscrowCancel - Simple', () => {
+ afterEach(cleanup)
it('renders with an expiration and offer', () => {
- const wrapper = createWrapper(mockEscrowCancel)
- expect(wrapper.find('[data-testid="escrow-amount"] .value')).toHaveText(
+ renderComponent(mockEscrowCancel)
+ expect(screen.getByTestId('escrow-amount')).toHaveTextContent(
`\uE900135.79 XRP`,
)
- expect(wrapper.find('[data-testid="escrow-cancel"] .value')).toHaveText(
+ expect(screen.getByTestId('escrow-cancel')).toHaveTextContent(
'rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56 - 9',
)
- expect(wrapper.find('[data-testid="escrow-cancel-tx"] .value')).toHaveText(
+ expect(screen.getByTestId('escrow-cancel-tx')).toHaveTextContent(
`A979AD5C6A6C844913DA51D71BF5F0B8E254D9A211FA837C4B322C4A8FD358E6`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelTableDetail.test.tsx b/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelTableDetail.test.tsx
index be2e5f173..670318ee7 100644
--- a/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowCancel/test/EscrowCancelTableDetail.test.tsx
@@ -1,19 +1,20 @@
+import { cleanup } from '@testing-library/react'
import { TableDetail } from '../TableDetail'
import mockEscrowCancel from './mock_data/EscrowCancel.json'
-import { createTableDetailWrapperFactory } from '../../test'
+import { createTableDetailRenderFactory } from '../../test'
import i18nTestConfigEnUS from '../../../../../../i18n/testConfigEnglish'
-const createWrapper = createTableDetailWrapperFactory(
+const renderComponent = createTableDetailRenderFactory(
TableDetail,
i18nTestConfigEnUS,
)
-describe('EscrowCancelTableDetail', () => {
+describe('EscrowCancel - TableDetail', () => {
+ afterEach(cleanup)
it('renders EscrowCancel without crashing', () => {
- const wrapper = createWrapper(mockEscrowCancel)
- expect(wrapper).toHaveText(
+ const { container } = renderComponent(mockEscrowCancel)
+ expect(container).toHaveTextContent(
'cancel escrow rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56 - 9',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateDescription.test.tsx b/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateDescription.test.tsx
index 0c256b19e..d62e51128 100644
--- a/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateDescription.test.tsx
@@ -1,15 +1,16 @@
+import { cleanup } from '@testing-library/react'
import EscrowCreate from './mock_data/EscrowCreate.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description)
+const renderComponent = createDescriptionRenderFactory(Description)
-describe('EscrowCreateDescription', () => {
+describe('EscrowCreate - Description', () => {
+ afterEach(cleanup)
it('renders description for EscrowCreate', () => {
- const wrapper = createWrapper(EscrowCreate)
- expect(wrapper.html()).toBe(
+ const { container } = renderComponent(EscrowCreate)
+ expect(container.innerHTML).toBe(
'The escrow is fromrLbgNAngLq3HABBXK4uPGCHrqeZwgaYi8qtorLbgNAngLq3HABBXK4uPGCHrqeZwgaYi7qescrow_condition A0258020886F982742772F414243855DC13B348FC78FB3D5119412C8A6480114E36A4451810120
escrowed_amount \uE900997.50XRP
describe_cancel_after March 1, 2020 at 8:54:20 AM UTC
describe_finish_after March 1, 2020 at 9:01:00 AM UTC
',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateSimple.test.tsx b/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateSimple.test.tsx
index 27da075d6..a0298da58 100644
--- a/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateSimple.test.tsx
@@ -1,21 +1,22 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import mockEscrowCreate from './mock_data/EscrowCreate.json'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('EscrowCreateSimple', () => {
+describe('EscrowCreate - Simple', () => {
+ afterEach(cleanup)
it('renders with an expiration and offer', () => {
- const wrapper = createWrapper(mockEscrowCreate)
- expect(wrapper.find('[data-testid="escrow-amount"] .value')).toHaveText(
+ renderComponent(mockEscrowCreate)
+ expect(screen.getByTestId('escrow-amount')).toHaveTextContent(
`\uE900997.50 XRP`,
)
- expect(
- wrapper.find('[data-testid="escrow-destination"] .value'),
- ).toHaveText(`rLbgNAngLq3HABBXK4uPGCHrqeZwgaYi7q`)
- expect(wrapper.find('[data-testid="escrow-condition"] .value')).toHaveText(
+ expect(screen.getByTestId('escrow-destination')).toHaveTextContent(
+ `rLbgNAngLq3HABBXK4uPGCHrqeZwgaYi7q`,
+ )
+ expect(screen.getByTestId('escrow-condition')).toHaveTextContent(
`A0258020886F982742772F414243855DC13B348FC78FB3D5119412C8A6480114E36A4451810120`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateTableDetail.test.tsx b/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateTableDetail.test.tsx
index 8bdca0c92..15e420e3b 100644
--- a/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowCreate/test/EscrowCreateTableDetail.test.tsx
@@ -1,26 +1,26 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import mockEscrowCreate from './mock_data/EscrowCreate.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('EscrowCreateTableDetail', () => {
+ afterEach(cleanup)
it('renders EscrowCreate without crashing', () => {
- const wrapper = createWrapper(mockEscrowCreate)
- expect(wrapper.find('[data-testid="account"]')).toHaveText(
- ` rLbgNAngLq3HABBXK4uPGCHrqeZwgaYi7q `,
+ renderComponent(mockEscrowCreate)
+ expect(screen.getByTestId('account')).toHaveTextContent(
+ `rLbgNAngLq3HABBXK4uPGCHrqeZwgaYi7q`,
)
- expect(wrapper.find('[data-testid="amount"]')).toHaveText(`997.50 XRP`)
- expect(wrapper.find('[data-testid="condition"]')).toHaveText(
- ` A0258020886F982742772F414243855DC13B348FC78FB3D5119412C8A6480114E36A4451810120 `,
+ expect(screen.getByTestId('amount')).toHaveTextContent(`997.50 XRP`)
+ expect(screen.getByTestId('condition')).toHaveTextContent(
+ `A0258020886F982742772F414243855DC13B348FC78FB3D5119412C8A6480114E36A4451810120`,
)
- expect(wrapper.find('[data-testid="finish_after"]')).toHaveText(
+ expect(screen.getByTestId('finish_after')).toHaveTextContent(
`March 1, 2020 at 9:01:00 AM UTC`,
)
- expect(wrapper.find('[data-testid="cancel_after"]')).toHaveText(
+ expect(screen.getByTestId('cancel_after')).toHaveTextContent(
`March 1, 2020 at 8:54:20 AM UTC`,
)
-
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowFinish/TableDetail.tsx b/src/containers/shared/components/Transaction/EscrowFinish/TableDetail.tsx
index 6fec08777..708ed624f 100644
--- a/src/containers/shared/components/Transaction/EscrowFinish/TableDetail.tsx
+++ b/src/containers/shared/components/Transaction/EscrowFinish/TableDetail.tsx
@@ -18,13 +18,13 @@ export const TableDetail = (props: any) => {
)}
{amount && (
-
+
)}
{fulfillment && (
-
+
{t('fulfillment')}
{fulfillment}
diff --git a/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishDescription.test.tsx b/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishDescription.test.tsx
index 558762aa2..d34488b90 100644
--- a/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishDescription.test.tsx
@@ -1,15 +1,16 @@
+import { cleanup } from '@testing-library/react'
import EscrowFinish from './mock_data/EscrowFinish.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description)
+const renderComponent = createDescriptionRenderFactory(Description)
-describe('EscrowFinishDescription', () => {
+describe('EscrowFinish - Description', () => {
+ afterEach(cleanup)
it('renders description for EscrowFinish', () => {
- const wrapper = createWrapper(EscrowFinish)
- expect(wrapper.html()).toBe(
+ const { container } = renderComponent(EscrowFinish)
+ expect(container.innerHTML).toBe(
'
The escrow was created by
r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8with transaction
3E2E75...escrow_finish_fullfillment_desc Fulfillment
',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishSimple.test.tsx b/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishSimple.test.tsx
index 32c67a94d..34fa7dfa0 100644
--- a/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishSimple.test.tsx
@@ -1,18 +1,19 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockEscrowFinish from './mock_data/EscrowFinish.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('EscrowFinishSimple', () => {
+describe('EscrowFinish - Simple', () => {
+ afterEach(cleanup)
it('renders with an expiration and offer', () => {
- const wrapper = createWrapper(mockEscrowFinish)
- expect(wrapper.find('[data-testid="escrow-amount"] .value')).toHaveText(
+ renderComponent(mockEscrowFinish)
+ expect(screen.getByTestId('escrow-amount')).toHaveTextContent(
`\uE9000.0154 XRP`,
)
- expect(wrapper.find('[data-testid="escrow-tx"] .value')).toHaveText(
+ expect(screen.getByTestId('escrow-tx')).toHaveTextContent(
`3E2E755FA75FF1020C39E2ECC407E9F1C0E49A7229EDD15FF93B9F869878F1CC`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishTableDetail.test.tsx b/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishTableDetail.test.tsx
index 7bc188a40..bfa947ed1 100644
--- a/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/EscrowFinish/test/EscrowFinishTableDetail.test.tsx
@@ -1,21 +1,22 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import mockEscrowFinish from './mock_data/EscrowFinish.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
-describe('EscrowFinishTableDetail', () => {
+describe('EscrowFinish - TableDetail', () => {
+ afterEach(cleanup)
it('renders EscrowFinish without crashing', () => {
- const wrapper = createWrapper(mockEscrowFinish)
- expect(wrapper.find('[data-testid="escrow-account"]')).toHaveText(
+ renderComponent(mockEscrowFinish)
+ expect(screen.getByTestId('escrow-account')).toHaveTextContent(
`finish_escrowr4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8 -28`,
)
- expect(wrapper.find('[data-testid="escrow-amount"]')).toHaveText(
+ expect(screen.getByTestId('escrow-amount')).toHaveTextContent(
`\uE9000.0154 XRP`,
)
- expect(wrapper.find('[data-testid="escrow-fullfillment"]')).toHaveText(
- `fulfillment Fulfillment `,
+ expect(screen.getByTestId('escrow-fulfillment')).toHaveTextContent(
+ `fulfillment Fulfillment`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/MPTokenAuthorize/Simple.tsx b/src/containers/shared/components/Transaction/MPTokenAuthorize/Simple.tsx
index 9823dfe4f..f046ba292 100644
--- a/src/containers/shared/components/Transaction/MPTokenAuthorize/Simple.tsx
+++ b/src/containers/shared/components/Transaction/MPTokenAuthorize/Simple.tsx
@@ -13,11 +13,11 @@ export const Simple: TransactionSimpleComponent = ({
return (
<>
-
+
{MPTokenHolder && (
-
+
)}
diff --git a/src/containers/shared/components/Transaction/MPTokenAuthorize/test/MPTokenAuthorizeSimple.test.jsx b/src/containers/shared/components/Transaction/MPTokenAuthorize/test/MPTokenAuthorizeSimple.test.jsx
index 932a18cc1..f8d3edea5 100644
--- a/src/containers/shared/components/Transaction/MPTokenAuthorize/test/MPTokenAuthorizeSimple.test.jsx
+++ b/src/containers/shared/components/Transaction/MPTokenAuthorize/test/MPTokenAuthorizeSimple.test.jsx
@@ -1,66 +1,67 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { expectSimpleRowText, expectSimpleRowNotToExist } from '../../test'
+import {
+ createSimpleRenderFactory,
+ expectSimpleRowText,
+ expectSimpleRowNotToExist,
+} from '../../test'
import transactionSuccess from './mock_data/MPTokenAuthorize.json'
import transactionFail from './mock_data/MPTokenAuthorize_Fail.json'
import transactionWithHolder from './mock_data/MPTokenAuthorize_WithHolder.json'
import transactionWithHolderFail from './mock_data/MPTokenAuthorize_WithHolderFail.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('MPTokenAuthorize', () => {
+ afterEach(cleanup)
it('handles MPTokenAuthorize w/o holder simple view ', () => {
- const wrapper = createWrapper(transactionSuccess)
+ renderComponent(transactionSuccess)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'000005F398B624EBD06822198649C920C8B20ADB8EBE745E',
)
- expectSimpleRowNotToExist(wrapper, 'mpt-holder')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'mpt-holder')
})
it('handles MPTokenAuthorize view w/ holder simple view ', () => {
- const wrapper = createWrapper(transactionWithHolder)
+ renderComponent(transactionWithHolder)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'0000130B63FC523E33FDF4D1318D8D484B0D1111098CFD0B',
)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-holder',
'rK3bB9myvWoMaLbLnpksGx2Zz58BL225am',
)
- wrapper.unmount()
})
it('handles failed MPTokenAuthorize view w/ holder simple view ', () => {
- const wrapper = createWrapper(transactionWithHolderFail)
+ renderComponent(transactionWithHolderFail)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'00000F76D46440EE21F74E5B2398315BC1CFEB9A7EB48A14',
)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-holder',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- wrapper.unmount()
})
it('handles failed MPTokenAuthorize w/o holder simple view ', () => {
- const wrapper = createWrapper(transactionFail)
+ renderComponent(transactionFail)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'0000098410531B842DEECCF4ABB1268C931EB71D9F6A1B64',
)
- expectSimpleRowNotToExist(wrapper, 'mpt-holder')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'mpt-holder')
})
})
diff --git a/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/Simple.tsx b/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/Simple.tsx
index 218ae93d2..28a9c62a6 100644
--- a/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/Simple.tsx
+++ b/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/Simple.tsx
@@ -24,7 +24,7 @@ export const Simple: TransactionSimpleComponent = ({
return (
<>
{issuanceID && (
-
+
)}
@@ -32,13 +32,13 @@ export const Simple: TransactionSimpleComponent = ({
{assetScale}
)}
{transferFee && (
-
+
{formattedFee}
)}
@@ -46,7 +46,7 @@ export const Simple: TransactionSimpleComponent = ({
{maxAmount}
@@ -55,7 +55,7 @@ export const Simple: TransactionSimpleComponent = ({
{isValidJsonString(metadata) ? (
diff --git a/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/test/MPTokenIssuanceCreateSimple.test.jsx b/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/test/MPTokenIssuanceCreateSimple.test.jsx
index 0c82efab4..59f01e22e 100644
--- a/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/test/MPTokenIssuanceCreateSimple.test.jsx
+++ b/src/containers/shared/components/Transaction/MPTokenIssuanceCreate/test/MPTokenIssuanceCreateSimple.test.jsx
@@ -1,27 +1,27 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import transactionSuccess from './mock_data/MPTokenIssuanceCreate.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('MPTokenIssuanceCreate', () => {
+ afterEach(cleanup)
it('handles MPTokenIssuanceCreate simple view ', () => {
- const wrapper = createWrapper(transactionSuccess)
+ renderComponent(transactionSuccess)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'0000157844C3F3B57A8B579FEE1033CC8E8498729D063617',
)
- expectSimpleRowText(wrapper, 'mpt-asset-scale', '2')
- expectSimpleRowText(wrapper, 'mpt-max-amount', '9223372036854775807')
+ expectSimpleRowText(screen, 'mpt-asset-scale', '2')
+ expectSimpleRowText(screen, 'mpt-max-amount', '9223372036854775807')
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-metadata',
'https://ipfs.io/ipfs/QmZnjmB9Tk4xaA9E679ytrPXda3beWMLUnMB5RFj1eStLp',
)
- expectSimpleRowText(wrapper, 'mpt-fee', '0.010%')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'mpt-fee', '0.010%')
})
})
diff --git a/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/Simple.tsx b/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/Simple.tsx
index 2b9bb6676..0b13f8eb8 100644
--- a/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/Simple.tsx
+++ b/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/Simple.tsx
@@ -11,7 +11,7 @@ export const Simple: TransactionSimpleComponent = ({
const { t } = useTranslation()
return (
-
+
)
diff --git a/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/test/MPTokenIssuanceDestroySimple.test.jsx b/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/test/MPTokenIssuanceDestroySimple.test.jsx
index ee9a5b7c0..838bcf414 100644
--- a/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/test/MPTokenIssuanceDestroySimple.test.jsx
+++ b/src/containers/shared/components/Transaction/MPTokenIssuanceDestroy/test/MPTokenIssuanceDestroySimple.test.jsx
@@ -1,29 +1,28 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import transactionSuccess from './mock_data/MPTokenIssuanceDestroy.json'
import transactionFail from './mock_data/MPTokenIssuanceDestroy_Fail.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('MPTokenIssuanceDestroy', () => {
+ afterEach(cleanup)
it('handles MPTokenIssuanceDestroy simple view ', () => {
- const wrapper = createWrapper(transactionSuccess)
+ renderComponent(transactionSuccess)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'0000071E15A457415B9A921957CA1958F0E3B8A049BE8627',
)
- wrapper.unmount()
})
it('handles failed MPTokenIssuanceDestroy simple view ', () => {
- const wrapper = createWrapper(transactionFail)
+ renderComponent(transactionFail)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'0000097E2ACB52C693EABBB156034140B2ED5E9522C4ACF4',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/MPTokenIssuanceSet/Simple.tsx b/src/containers/shared/components/Transaction/MPTokenIssuanceSet/Simple.tsx
index 9f0b13ca8..a5b14e711 100644
--- a/src/containers/shared/components/Transaction/MPTokenIssuanceSet/Simple.tsx
+++ b/src/containers/shared/components/Transaction/MPTokenIssuanceSet/Simple.tsx
@@ -13,11 +13,11 @@ export const Simple: TransactionSimpleComponent = ({
return (
<>
-
+
{MPTokenHolder && (
-
+
)}
diff --git a/src/containers/shared/components/Transaction/MPTokenIssuanceSet/test/MPTokenIssuanceSetSimple.test.jsx b/src/containers/shared/components/Transaction/MPTokenIssuanceSet/test/MPTokenIssuanceSetSimple.test.jsx
index 2083e158c..08d97bd4d 100644
--- a/src/containers/shared/components/Transaction/MPTokenIssuanceSet/test/MPTokenIssuanceSetSimple.test.jsx
+++ b/src/containers/shared/components/Transaction/MPTokenIssuanceSet/test/MPTokenIssuanceSetSimple.test.jsx
@@ -1,53 +1,55 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
-import { expectSimpleRowText, expectSimpleRowNotToExist } from '../../test'
+import {
+ createSimpleRenderFactory,
+ expectSimpleRowText,
+ expectSimpleRowNotToExist,
+} from '../../test'
import transactionSuccess from './mock_data/MPTokenIssuanceSet.json'
import transactionNoHolder from './mock_data/MPTokenIssuanceSet_NoHolder.json'
import transactionFail from './mock_data/MPTokenIssuanceSet_Fail.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('MPTokenIssuanceSet', () => {
+ afterEach(cleanup)
it('handles MPTokenIssuanceSet simple view ', () => {
- const wrapper = createWrapper(transactionSuccess)
+ renderComponent(transactionSuccess)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'00000BED9E4ADA3DCC1BE78683C4B623A74013818160590C',
)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-holder',
'r9hF4e3e6kLuxLobPwfQa2wzXZMDvBDeUg',
)
- wrapper.unmount()
})
it('handles MPTokenIssuanceSet simple view w/o holder ', () => {
- const wrapper = createWrapper(transactionNoHolder)
+ renderComponent(transactionNoHolder)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'000002609BB39CEC721B5AB337B6BD862ACD2811CBBB5F18',
)
- expectSimpleRowNotToExist(wrapper, 'mpt-holder')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'mpt-holder')
})
it('handles failed MPTokenIssuanceSet simple view ', () => {
- const wrapper = createWrapper(transactionFail)
+ renderComponent(transactionFail)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-issuance-id',
'00000F83146C83112AED215CD345F8E7327459BFCF6B8062',
)
expectSimpleRowText(
- wrapper,
+ screen,
'mpt-holder',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/Simple.tsx b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/Simple.tsx
index e2ca6d49a..395bf2c9f 100644
--- a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/Simple.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/Simple.tsx
@@ -38,7 +38,7 @@ export const Simple: TransactionSimpleComponent = ({
>
-
+
>
diff --git a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/test/NFTokenAcceptOfferSimple.test.tsx b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/test/NFTokenAcceptOfferSimple.test.tsx
index f324577bc..be1584f44 100644
--- a/src/containers/shared/components/Transaction/NFTokenAcceptOffer/test/NFTokenAcceptOfferSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenAcceptOffer/test/NFTokenAcceptOfferSimple.test.tsx
@@ -1,4 +1,5 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import transactionBuy from './mock_data/NFTokenAcceptOffer_Buy.json'
import transactionSell from './mock_data/NFTokenAcceptOffer_Sell.json'
@@ -6,72 +7,69 @@ import transactionFailure from './mock_data/NFTokenAcceptOffer_Failure.json'
import transactionBroker from './mock_data/NFTokenAcceptOffer_Broker.json'
import { expectSimpleRowText, expectSimpleRowNotToExist } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('NFTokenAcceptOffer', () => {
+describe('NFTokenAcceptOffer - Simple', () => {
+ afterEach(cleanup)
it('handles NFTokenAcceptOffer Buy simple view ', () => {
- const wrapper = createWrapper(transactionBuy)
+ renderComponent(transactionBuy)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C29ABA6A90000000D',
)
expectSimpleRowText(
- wrapper,
+ screen,
'offer-id',
'8278760A246D4464EE701D503091B9DB0D9790DD2BBE9CAABCA45B04A1A25B6B',
)
- expectSimpleRowText(wrapper, 'amount', '\uE9000.0001 XRP')
- expectSimpleRowText(wrapper, 'buyer', 'rfFRmXUR1yfxeUfXj7WwKhETrtToYx1hYh')
- expectSimpleRowText(wrapper, 'seller', 'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'offer-amount', '\uE9000.0001 XRP')
+ expectSimpleRowText(screen, 'buyer', 'rfFRmXUR1yfxeUfXj7WwKhETrtToYx1hYh')
+ expectSimpleRowText(screen, 'seller', 'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g')
})
it('handles NFTokenAcceptOffer Sell simple view ', () => {
- const wrapper = createWrapper(transactionSell)
+ renderComponent(transactionSell)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C216B9CBF00000023',
)
expectSimpleRowText(
- wrapper,
+ screen,
'offer-id',
'505E7F1E1EA989C0B0196AB7F503ACACAC7A9640C27B58A5E3C9DD31E88848D4',
)
- expectSimpleRowText(wrapper, 'amount', '\uE9000.000102 XRP')
- expectSimpleRowText(wrapper, 'buyer', 'rfFRmXUR1yfxeUfXj7WwKhETrtToYx1hYh')
- expectSimpleRowText(wrapper, 'seller', 'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'offer-amount', '\uE9000.000102 XRP')
+ expectSimpleRowText(screen, 'buyer', 'rfFRmXUR1yfxeUfXj7WwKhETrtToYx1hYh')
+ expectSimpleRowText(screen, 'seller', 'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g')
})
it('handles NFTokenAcceptOffer Sell Failure simple view ', () => {
- const wrapper = createWrapper(transactionFailure)
+ renderComponent(transactionFailure)
expectSimpleRowText(
- wrapper,
+ screen,
'offer-id',
'17AFFE8C8D94554EB3A31A517B05C16085777FAEA9ACEDDCDE9D7CFD7B988D01',
)
- expectSimpleRowNotToExist(wrapper, 'token-id')
- expectSimpleRowNotToExist(wrapper, 'amount')
- expectSimpleRowNotToExist(wrapper, 'buyer')
- expectSimpleRowNotToExist(wrapper, 'seller')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'token-id')
+ expectSimpleRowNotToExist(screen, 'offer-amount')
+ expectSimpleRowNotToExist(screen, 'buyer')
+ expectSimpleRowNotToExist(screen, 'seller')
})
it('handles NFTokenAcceptOffer from Broker simple view ', () => {
- const wrapper = createWrapper(transactionBroker)
+ renderComponent(transactionBroker)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'00081B581189F5687DBB7516339D6CCB5593D96622AD82DF08CFDA8600000A17',
)
- expect(wrapper.find('[data-testid="offer-id"] .value').length).toBe(2)
- expectSimpleRowText(wrapper, 'amount', '\uE9002,500.00 XRP')
- expectSimpleRowText(wrapper, 'buyer', 'rNYKGnHrjSnKXQGgACciyCLg4xRcwWZixN')
- expectSimpleRowText(wrapper, 'seller', 'rnp9DA6H2tLH7YFkgpjoVREB2yccYv56Sg')
- wrapper.unmount()
+ expect(screen.getAllByTestId('offer-id').length).toBe(2)
+ expectSimpleRowText(screen, 'offer-amount', '\uE9002,500.00 XRP')
+ expectSimpleRowText(screen, 'buyer', 'rNYKGnHrjSnKXQGgACciyCLg4xRcwWZixN')
+ expectSimpleRowText(screen, 'seller', 'rnp9DA6H2tLH7YFkgpjoVREB2yccYv56Sg')
})
})
diff --git a/src/containers/shared/components/Transaction/NFTokenBurn/test/NFTokenBurnSimple.test.tsx b/src/containers/shared/components/Transaction/NFTokenBurn/test/NFTokenBurnSimple.test.tsx
index 73d99fb27..36458d0c7 100644
--- a/src/containers/shared/components/Transaction/NFTokenBurn/test/NFTokenBurnSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenBurn/test/NFTokenBurnSimple.test.tsx
@@ -1,5 +1,6 @@
+import { cleanup, screen } from '@testing-library/react'
import {
- createSimpleWrapperFactory,
+ createSimpleRenderFactory,
expectSimpleRowText,
expectSimpleRowNotToExist,
} from '../../test'
@@ -7,28 +8,27 @@ import { Simple } from '../Simple'
import transaction from './mock_data/NFTokenBurn.json'
import transactionByIssuer from './mock_data/NFTokenBurnByIssuer.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('NFTokenBurn', () => {
+ afterEach(cleanup)
it('handles NFTokenBurn simple view ', () => {
- const wrapper = createWrapper(transaction)
+ renderComponent(transaction)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C29ABA6A90000000D',
)
- expectSimpleRowNotToExist(wrapper, 'owner')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'owner')
})
it('handles NFTokenBurn when the burner is not the owner', () => {
- const wrapper = createWrapper(transactionByIssuer)
+ renderComponent(transactionByIssuer)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'00090000DF7682C6F61329B887798E2ABB518BF1C923F4010000099B00000000',
)
- expectSimpleRowText(wrapper, 'owner', 'rH3Jr1zwADrokm2niuJLEAD5NuoVwBvzpk')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'owner', 'rH3Jr1zwADrokm2niuJLEAD5NuoVwBvzpk')
})
})
diff --git a/src/containers/shared/components/Transaction/NFTokenCancelOffer/Simple.tsx b/src/containers/shared/components/Transaction/NFTokenCancelOffer/Simple.tsx
index 6df38b784..7a74cd066 100644
--- a/src/containers/shared/components/Transaction/NFTokenCancelOffer/Simple.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenCancelOffer/Simple.tsx
@@ -30,7 +30,7 @@ export const Simple: TransactionSimpleComponent = ({
>
-
+
diff --git a/src/containers/shared/components/Transaction/NFTokenCancelOffer/test/NFTokenCancelOfferSimple.test.tsx b/src/containers/shared/components/Transaction/NFTokenCancelOffer/test/NFTokenCancelOfferSimple.test.tsx
index 5e9087e77..5b04942c6 100644
--- a/src/containers/shared/components/Transaction/NFTokenCancelOffer/test/NFTokenCancelOfferSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenCancelOffer/test/NFTokenCancelOfferSimple.test.tsx
@@ -1,38 +1,25 @@
-import { BrowserRouter as Router } from 'react-router-dom'
-import { mount } from 'enzyme'
-import { I18nextProvider } from 'react-i18next'
-import { QueryClientProvider } from 'react-query'
-import { Simple as NFTokenCancelOffer } from '../Simple'
+import { cleanup, screen } from '@testing-library/react'
+import { Simple } from '../Simple'
import transaction from './mock_data/NFTokenCancelOffer.json'
-import summarizeTransaction from '../../../../../../rippled/lib/txSummary'
-import i18n from '../../../../../../i18n/testConfig'
-import { queryClient } from '../../../../QueryClient'
+import { createSimpleRenderFactory } from '../../test'
+
+const renderComponent = createSimpleRenderFactory(Simple)
describe('NFTokenCancelOffer', () => {
+ afterEach(cleanup)
it.only('handles NFTokenCancelOffer simple view ', () => {
- const wrapper = mount(
-
-
-
-
-
-
- ,
- )
- expect(wrapper.find('[data-testid="token-id"] .value')).toHaveText(
+ renderComponent(transaction)
+ expect(screen.getByTestId('token-id')).toHaveTextContent(
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C258BA1B200000018',
)
- expect(wrapper.find('[data-testid="offer-id"] .value')).toHaveText(
+ expect(screen.getByTestId('offer-id')).toHaveTextContent(
'35F3D6D99548FA5F5315580FBF8BA6B15CAA2CAE93023D5CE4FDC130602BC5C3',
)
- expect(wrapper.find('[data-testid="amount"] .value')).toHaveText(
+ expect(screen.getByTestId('offer-amount')).toHaveTextContent(
'$100.00 USD.r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g',
)
- expect(wrapper.find('[data-testid="offerer"] .value')).toHaveText(
+ expect(screen.getByTestId('offerer')).toHaveTextContent(
'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/NFTokenCreateOffer/Simple.tsx b/src/containers/shared/components/Transaction/NFTokenCreateOffer/Simple.tsx
index 4d57365c0..88c697bda 100644
--- a/src/containers/shared/components/Transaction/NFTokenCreateOffer/Simple.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenCreateOffer/Simple.tsx
@@ -39,7 +39,7 @@ export const Simple: TransactionSimpleComponent = ({
-
+
>
diff --git a/src/containers/shared/components/Transaction/NFTokenCreateOffer/test/NFTokenCreateOfferSimple.test.tsx b/src/containers/shared/components/Transaction/NFTokenCreateOffer/test/NFTokenCreateOfferSimple.test.tsx
index 110891c70..3d5e45d3b 100644
--- a/src/containers/shared/components/Transaction/NFTokenCreateOffer/test/NFTokenCreateOfferSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenCreateOffer/test/NFTokenCreateOfferSimple.test.tsx
@@ -1,89 +1,87 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import {
+ createSimpleRenderFactory,
+ expectSimpleRowNotToExist,
+ expectSimpleRowText,
+} from '../../test'
import { Simple } from '../Simple'
import transactionBuy from './mock_data/NFTokenCreateOffer_Buy.json'
import transactionSell from './mock_data/NFTokenCreateOffer_Sell.json'
import transactionFailed from './mock_data/NFTokenCreateOfferFailed.json'
import transactionDestination from './mock_data/NFTokenCreateOfferDestination.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('NFTokenCreateOffer', () => {
+ afterEach(cleanup)
it('handles NFTokenCreateOffer buy simple view ', () => {
- const wrapper = createWrapper(transactionBuy)
+ renderComponent(transactionBuy)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C2DCBAB9D00000002',
)
expectSimpleRowText(
- wrapper,
+ screen,
'offer-id',
'3D1C297DA5B831267CCF692F8A023688D6A4BD5AFAE9A746D5C4E0B15D256B29',
)
- expectSimpleRowText(wrapper, 'owner', 'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g')
- expectSimpleRowText(wrapper, 'amount', '\uE9000.0001 XRP')
- expect(wrapper.find('[data-testid="buyer-or-seller"] .label')).toHaveText(
- 'buyer',
- )
+ expectSimpleRowText(screen, 'owner', 'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g')
+ expectSimpleRowText(screen, 'offer-amount', '\uE9000.0001 XRP')
+ expect(screen.getByTestId('buyer-or-seller')).toHaveTextContent('buyer')
expectSimpleRowText(
- wrapper,
+ screen,
'buyer-or-seller',
'rfFRmXUR1yfxeUfXj7WwKhETrtToYx1hYh',
)
- expect(wrapper.find('[data-testid="destination"] .value')).not.toExist()
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'destination')
})
it('handles NFTokenCreateOffer sell simple view ', () => {
- const wrapper = createWrapper(transactionSell)
+ renderComponent(transactionSell)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C29ABA6A90000000D',
)
expectSimpleRowText(
- wrapper,
+ screen,
'offer-id',
'F660CA62E16B8067649052E8FCE947049FC6EF0D8B42EF7E5819997EC5AE45B6',
)
- expect(wrapper.find('[data-testid="owner"] .value')).not.toExist()
+ expectSimpleRowNotToExist(screen, 'owner')
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'offer-amount',
'$100.00 USD.r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g',
)
- expect(wrapper.find('[data-testid="buyer-or-seller"] .label')).toHaveText(
- 'seller',
- )
+ expect(screen.getByTestId('buyer-or-seller')).toHaveTextContent('seller')
expectSimpleRowText(
- wrapper,
+ screen,
'buyer-or-seller',
'r9AExd6v3keXaXa3nXAMHHcP9nWy9Aef2g',
)
- expect(wrapper.find('[data-testid="destination"] .value')).not.toExist()
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'destination')
})
it('handles failed NFTokenCreateOffer transaction', () => {
- const wrapper = createWrapper(transactionFailed)
+ renderComponent(transactionFailed)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'00080000AC7377C74DD53E77C8161537F5EBF56B0CE8FD3BD392C2B800001702',
)
- expect(wrapper.find('[data-testid="offer-id"] .value')).not.toExist()
- expect(wrapper.find('[data-testid="owner"] .value')).not.toExist()
- expectSimpleRowText(wrapper, 'amount', '\uE900500.00 XRP')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'offer-id')
+ expectSimpleRowNotToExist(screen, 'owner')
+ expectSimpleRowText(screen, 'offer-amount', '\uE900500.00 XRP')
})
it('handles NFTokenCreateOffer with destination', () => {
- const wrapper = createWrapper(transactionDestination)
+ renderComponent(transactionDestination)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rpdUbED32X3YXRPBGzSv8gMTJE66t3sji9',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/NFTokenMint/test/NFTokenMintSimple.test.tsx b/src/containers/shared/components/Transaction/NFTokenMint/test/NFTokenMintSimple.test.tsx
index ffb8fd35a..5176e5f33 100644
--- a/src/containers/shared/components/Transaction/NFTokenMint/test/NFTokenMintSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/NFTokenMint/test/NFTokenMintSimple.test.tsx
@@ -1,7 +1,5 @@
-import { BrowserRouter as Router } from 'react-router-dom'
-import { mount } from 'enzyme'
-import { I18nextProvider } from 'react-i18next'
-import { Simple as NFTokenMint } from '../Simple'
+import { cleanup, screen } from '@testing-library/react'
+import { Simple } from '../Simple'
import transactionModified2 from './mock_data/NFTokenMintModified2.json'
import transactionModified1Created1 from './mock_data/NFTokenMintModified1Created1.json'
import transactionModified2Created1 from './mock_data/NFTokenMintMostModified2Created1.json'
@@ -9,181 +7,117 @@ import transactionWithIssuer from './mock_data/NFTokenMintWithIssuer.json'
import transactionModified4Created1 from './mock_data/NFTokenMintModified4Created1.json'
import transactionNullURI from './mock_data/NFTokenMintNullURI.json'
import transactionFailed from './mock_data/NFTokenMintFailed.json'
-import summarizeTransaction from '../../../../../../rippled/lib/txSummary'
-import i18n from '../../../../../../i18n/testConfig'
import { convertHexToString } from '../../../../../../rippled/lib/utils'
-import { expectSimpleRowText, expectSimpleRowNotToExist } from '../../test'
+import {
+ expectSimpleRowText,
+ expectSimpleRowNotToExist,
+ createSimpleRenderFactory,
+} from '../../test'
-describe('NFTokenMint', () => {
+const renderComponent = createSimpleRenderFactory(Simple)
+
+describe('NFTokenMint - Simple', () => {
+ afterEach(cleanup)
it('handles NFTokenMint that modified 2 nodes', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionModified2)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000800006203F49C21D5D6E022CB16DE3538F248662FC73C535743B40000001A',
)
- expectSimpleRowText(wrapper, 'token-taxon', '1')
- expectSimpleRowText(wrapper, 'token-uri', 'https://gregweisbrod.com')
- expectSimpleRowNotToExist(wrapper, 'token-fee')
- expectSimpleRowNotToExist(wrapper, 'token-issuer')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'token-taxon', '1')
+ expectSimpleRowText(screen, 'token-uri', 'https://gregweisbrod.com')
+ expectSimpleRowNotToExist(screen, 'token-fee')
+ expectSimpleRowNotToExist(screen, 'token-issuer')
})
it('handles NFTokenMint that modified 1 node and created 1 node', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionModified1Created1)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'0008000085D33F9C5481D3515029C9904D16F0109414D3A00000099A00000000',
)
- expectSimpleRowText(wrapper, 'token-taxon', '1')
- expectSimpleRowText(wrapper, 'token-uri', 'https://gregweisbrod.com')
- expectSimpleRowNotToExist(wrapper, 'token-fee')
- expectSimpleRowNotToExist(wrapper, 'token-issuer')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'token-taxon', '1')
+ expectSimpleRowText(screen, 'token-uri', 'https://gregweisbrod.com')
+ expectSimpleRowNotToExist(screen, 'token-fee')
+ expectSimpleRowNotToExist(screen, 'token-issuer')
})
it('handles NFTokenMint that modified 2 nodes and created 1 node', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionModified2Created1)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'0008000085D33F9C5481D3515029C9904D16F0109414D3A0DCBA29BA00000020',
)
- expectSimpleRowText(wrapper, 'token-taxon', '1')
- expectSimpleRowText(wrapper, 'token-uri', 'https://gregweisbrod.com')
- expectSimpleRowNotToExist(wrapper, 'token-fee')
- expectSimpleRowNotToExist(wrapper, 'token-issuer')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'token-taxon', '1')
+ expectSimpleRowText(screen, 'token-uri', 'https://gregweisbrod.com')
+ expectSimpleRowNotToExist(screen, 'token-fee')
+ expectSimpleRowNotToExist(screen, 'token-issuer')
})
it('handles NFTokenMint with issuer', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionWithIssuer)
- expect(wrapper.find('[data-testid="token-issuer"] .value')).toExist()
+ expect(screen.queryByTestId('token-issuer')).toBeDefined()
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000861A8A99B4460C2A4CCC90634FD9C7F51940AD9450BE30000099B00000000',
)
- expectSimpleRowText(wrapper, 'token-taxon', '0')
+ expectSimpleRowText(screen, 'token-taxon', '0')
expectSimpleRowText(
- wrapper,
+ screen,
'token-uri',
'ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi',
)
- expectSimpleRowText(wrapper, 'token-fee', '25.000%')
+ expectSimpleRowText(screen, 'token-fee', '25.000%')
expectSimpleRowText(
- wrapper,
+ screen,
'token-issuer',
'rGToUZ1JjRUdv1wXNXKMFn2o4wTM2DLkpg',
)
- wrapper.unmount()
})
it('handles NFTokenMint that modified 3 nodes', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionModified4Created1)
expectSimpleRowText(
- wrapper,
+ screen,
'token-id',
'000D0000B9BD7D214128A91ECECE5FCFF9BDB0D043567C51CFBEC443000063A7',
)
- expectSimpleRowText(wrapper, 'token-taxon', '1')
+ expectSimpleRowText(screen, 'token-taxon', '1')
expectSimpleRowText(
- wrapper,
+ screen,
'token-uri',
convertHexToString(
'516D5071416B3677777577796A71654C476F64665253375156774677394346736A6D363375485661556438387463',
) as string,
)
- wrapper.unmount()
})
it('handles NFTokenMint that has null URI', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionNullURI)
- expectSimpleRowNotToExist(wrapper, 'token-uri')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'token-uri')
})
it('handles NFTokenMint that failed', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ renderComponent(transactionFailed)
- expectSimpleRowNotToExist(wrapper, 'token-id')
- expectSimpleRowText(wrapper, 'token-taxon', '19')
+ expectSimpleRowNotToExist(screen, 'token-id')
+ expectSimpleRowText(screen, 'token-taxon', '19')
expectSimpleRowText(
- wrapper,
+ screen,
'token-uri',
convertHexToString(
'516D5071416B3677777577796A71654C476F64665253375156774677394346736A6D363375485661556438387463',
) as string,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelDescription.test.tsx b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelDescription.test.tsx
new file mode 100644
index 000000000..571811c5f
--- /dev/null
+++ b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelDescription.test.tsx
@@ -0,0 +1,17 @@
+import { cleanup, screen } from '@testing-library/react'
+import { createDescriptionRenderFactory } from '../../test'
+import { Description } from '../Description'
+import offerCancel from './mock_data/OfferCancel.json'
+
+const renderComponent = createDescriptionRenderFactory(Description)
+
+describe('OfferCancel: Description', () => {
+ afterEach(cleanup)
+ it('renders', () => {
+ renderComponent(offerCancel)
+
+ expect(screen.getByTestId('cancel-line')).toHaveTextContent(
+ 'offer_cancel_description15239384',
+ )
+ })
+})
diff --git a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelSimple.test.tsx b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelSimple.test.tsx
new file mode 100644
index 000000000..4fa443a6e
--- /dev/null
+++ b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelSimple.test.tsx
@@ -0,0 +1,15 @@
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
+import { Simple } from '../Simple'
+import offerCancel from './mock_data/OfferCancel.json'
+
+const renderComponent = createSimpleRenderFactory(Simple)
+
+describe('OfferCancel: Simple', () => {
+ afterEach(cleanup)
+ it('renders', () => {
+ renderComponent(offerCancel)
+
+ expectSimpleRowText(screen, 'cancel', '#15239384')
+ })
+})
diff --git a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelTableDetail.test.tsx b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelTableDetail.test.tsx
new file mode 100644
index 000000000..3f07f13b0
--- /dev/null
+++ b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCancelTableDetail.test.tsx
@@ -0,0 +1,14 @@
+import { cleanup } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
+import { TableDetail } from '../TableDetail'
+import offerCancel from './mock_data/OfferCancel.json'
+
+const renderComponent = createTableDetailRenderFactory(TableDetail)
+
+describe('OfferCancel: TableDetail', () => {
+ afterEach(cleanup)
+ it('renders', () => {
+ const { container } = renderComponent(offerCancel)
+ expect(container).toHaveTextContent('cancel_offer #15239384')
+ })
+})
diff --git a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateDescription.test.tsx b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateDescription.test.tsx
deleted file mode 100644
index 50f0f9051..000000000
--- a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateDescription.test.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { createDescriptionWrapperFactory } from '../../test'
-import { Description } from '../Description'
-import offerCancel from './mock_data/OfferCancel.json'
-
-const createWrapper = createDescriptionWrapperFactory(Description)
-
-describe('OfferCancel: Description', () => {
- it('renders', () => {
- const wrapper = createWrapper(offerCancel)
-
- expect(wrapper.find('[data-testid="cancel-line"]')).toHaveText(
- 'offer_cancel_description15239384',
- )
- })
-})
diff --git a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateSimple.test.tsx b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateSimple.test.tsx
deleted file mode 100644
index b3c1ef555..000000000
--- a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateSimple.test.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
-import { Simple } from '../Simple'
-import offerCancel from './mock_data/OfferCancel.json'
-
-const createWrapper = createSimpleWrapperFactory(Simple)
-
-describe('OfferCancel: Simple', () => {
- it('renders', () => {
- const wrapper = createWrapper(offerCancel)
-
- expectSimpleRowText(wrapper, 'cancel', '#15239384')
- })
-})
diff --git a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateTableDetail.test.tsx b/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateTableDetail.test.tsx
deleted file mode 100644
index 2c2932bc3..000000000
--- a/src/containers/shared/components/Transaction/OfferCancel/test/OfferCreateTableDetail.test.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { createTableDetailWrapperFactory } from '../../test'
-import { TableDetail } from '../TableDetail'
-import offerCancel from './mock_data/OfferCancel.json'
-
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
-
-describe('OfferCancel: TableDetail', () => {
- it('renders', () => {
- const wrapper = createWrapper(offerCancel)
-
- expect(wrapper).toHaveText('cancel_offer #15239384')
- })
-})
diff --git a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx
index 6aae61649..8c8b80807 100644
--- a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx
+++ b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx
@@ -13,7 +13,7 @@ const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => {
return (
<>
-
+
{`${Number(price)}`}
{
/>
-
+
-
+
{cancel && (
diff --git a/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateDescription.test.tsx b/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateDescription.test.tsx
index fd467dcde..20fa07bdc 100644
--- a/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateDescription.test.tsx
@@ -1,26 +1,26 @@
+import { cleanup } from '@testing-library/react'
import OfferCreate from './mock_data/OfferCreateWithExpirationAndCancel.json'
import OfferCreateInvertedCurrencies from './mock_data/OfferCreateInvertedCurrencies.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description)
+const renderComponent = createDescriptionRenderFactory(Description)
describe('OfferCreate: Description', () => {
+ afterEach(cleanup)
it('renders description for transaction with cancel and expiration', () => {
- const wrapper = createWrapper(OfferCreate)
+ const { container } = renderComponent(OfferCreate)
- expect(wrapper.html()).toBe(
+ expect(container.innerHTML).toBe(
'
offer_create_desc_line_2 612.52XRP/CSC
offer_create_desc_line_3 44866443
The offer expires
May 18, 2022 at 5:28:16 PM UTCunless cancelled before',
)
- wrapper.unmount()
})
it('renders description for transaction with inverted currencies', () => {
- const wrapper = createWrapper(OfferCreateInvertedCurrencies)
+ const { container } = renderComponent(OfferCreateInvertedCurrencies)
- expect(wrapper.html()).toBe(
+ expect(container.innerHTML).toBe(
'
offer_create_desc_line_2 0.34690XRP/USD
offer_create_desc_line_3 80543309
',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateSimple.test.tsx b/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateSimple.test.tsx
index 0953e75ac..c3c78d32b 100644
--- a/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateSimple.test.tsx
@@ -1,36 +1,33 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import mockOfferCreateWithCancel from './mock_data/OfferCreateWithExpirationAndCancel.json'
import mockOfferCreate from './mock_data/OfferCreate.json'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('OfferCreate: Simple', () => {
+ afterEach(cleanup)
it('renders with an expiration and offer', () => {
- const wrapper = createWrapper(mockOfferCreateWithCancel)
- expect(wrapper.find('[data-testid="amount"] .one-line')).toHaveText(
- '\uE900 XRP/CSC.rCSC',
- )
- expect(wrapper.find('[data-testid="cancel-id"] .value')).toHaveText(
- '#44866443',
- )
- expect(wrapper.find('[data-testid="amount-buy"] .value')).toHaveText(
+ renderComponent(mockOfferCreateWithCancel)
+ expect(screen.getByTestId('price')).toHaveTextContent('\uE900 XRP/CSC.rCSC')
+ expect(screen.getByTestId('cancel-id')).toHaveTextContent('#44866443')
+ expect(screen.getByTestId('amount-buy')).toHaveTextContent(
`\uE9001,764.293151 XRP`,
)
- expect(wrapper.find('[data-testid="amount-sell"] .value')).toHaveText(
+ expect(screen.getByTestId('amount-sell')).toHaveTextContent(
`1,080,661.95882 CSC.rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr`,
)
- wrapper.unmount()
})
it('renders', () => {
- const wrapper = createWrapper(mockOfferCreate)
+ renderComponent(mockOfferCreate)
- expect(wrapper.find('[data-testid="offer-id"] .value')).not.toExist()
- expect(wrapper.find('[data-testid="amount-buy"] .value')).toHaveText(
+ expect(screen.queryByTestId('offer-id')).toBeNull()
+ expect(screen.getByTestId('amount-buy')).toHaveTextContent(
`\uE90024,755.081083 XRP`,
)
- expect(wrapper.find('[data-testid="amount-sell"] .value')).toHaveText(
+ expect(screen.getByTestId('amount-sell')).toHaveTextContent(
`51.41523894 BCH.rcyS4CeCZVYvTiKcxj6Sx32ibKwcDHLds`,
)
})
diff --git a/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateTableDetail.test.tsx b/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateTableDetail.test.tsx
index 059b95d94..d34d6c7d3 100644
--- a/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/OfferCreate/test/OfferCreateTableDetail.test.tsx
@@ -1,49 +1,50 @@
+import { cleanup, screen } from '@testing-library/react'
import { TableDetail } from '../TableDetail'
import mockOfferCreateInvertedCurrencies from './mock_data/OfferCreateInvertedCurrencies.json'
import mockOfferCreateWithCancel from './mock_data/OfferCreateWithExpirationAndCancel.json'
import mockOfferCreate from './mock_data/OfferCreate.json'
-import { createTableDetailWrapperFactory } from '../../test'
+import { createTableDetailRenderFactory } from '../../test'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('OfferCreate: TableDetail', () => {
+ afterEach(cleanup)
it('renders with an expiration and offer', () => {
- const wrapper = createWrapper(mockOfferCreateWithCancel)
+ renderComponent(mockOfferCreateWithCancel)
- expect(wrapper.find('[data-testid="pair"]')).toHaveText(
+ expect(screen.getByTestId('pair')).toHaveTextContent(
'price:612.518 \uE900 XRP/CSC.rCSC',
)
- expect(wrapper.find('[data-testid="cancel-id"]')).toHaveText(
+ expect(screen.getByTestId('cancel-id')).toHaveTextContent(
'cancel_offer #44866443',
)
- expect(wrapper.find('[data-testid="amount-buy"]')).toHaveText(
+ expect(screen.getByTestId('amount-buy')).toHaveTextContent(
`\uE9001,764.293151 XRP`,
)
- expect(wrapper.find('[data-testid="amount-sell"]')).toHaveText(
+ expect(screen.getByTestId('amount-sell')).toHaveTextContent(
`1,080,661.95882 CSC.rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr`,
)
- wrapper.unmount()
})
it('renders', () => {
- const wrapper = createWrapper(mockOfferCreate)
+ renderComponent(mockOfferCreate)
- expect(wrapper.find('[data-testid="pair"]')).toHaveText(
+ expect(screen.getByTestId('pair')).toHaveTextContent(
'price:0.00207696 \uE900 XRP/BCH.rcyS',
)
- expect(wrapper.find('[data-testid="offer-id"]')).not.toExist()
- expect(wrapper.find('[data-testid="amount-buy"]')).toHaveText(
+ expect(screen.queryByTestId('offer-id')).toBeNull()
+ expect(screen.getByTestId('amount-buy')).toHaveTextContent(
`\uE90024,755.081083 XRP`,
)
- expect(wrapper.find('[data-testid="amount-sell"]')).toHaveText(
+ expect(screen.getByTestId('amount-sell')).toHaveTextContent(
`51.41523894 BCH.rcyS4CeCZVYvTiKcxj6Sx32ibKwcDHLds`,
)
})
it('renders inverted currencies', () => {
- const wrapper = createWrapper(mockOfferCreateInvertedCurrencies)
+ renderComponent(mockOfferCreateInvertedCurrencies)
- expect(wrapper.find('[data-testid="pair"]')).toHaveText(
+ expect(screen.getByTestId('pair')).toHaveTextContent(
'price:0.346896 \uE900 XRP/USD.rvYA',
)
})
diff --git a/src/containers/shared/components/Transaction/OracleDelete/TableDetail.tsx b/src/containers/shared/components/Transaction/OracleDelete/TableDetail.tsx
index 09886858f..1724efb23 100644
--- a/src/containers/shared/components/Transaction/OracleDelete/TableDetail.tsx
+++ b/src/containers/shared/components/Transaction/OracleDelete/TableDetail.tsx
@@ -7,7 +7,7 @@ export const TableDetail = ({
}: TransactionTableDetailProps
) => {
const { t } = useTranslation()
return (
-
+
{t('oracle_document_id')}:
{tx.OracleDocumentID}
diff --git a/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteSimple.test.tsx b/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteSimple.test.tsx
index b1320cf7a..be7ce4283 100644
--- a/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteSimple.test.tsx
@@ -1,12 +1,13 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { screen, cleanup } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import OracleDelete from './mock_data/OracleDelete.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('OracleDelete: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(OracleDelete)
- expectSimpleRowText(wrapper, 'oracle-document-id', '1')
- wrapper.unmount()
+ renderComponent(OracleDelete)
+ expectSimpleRowText(screen, 'oracle-document-id', '1')
})
})
diff --git a/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteTableDetail.test.tsx b/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteTableDetail.test.tsx
index 339a340d3..eb7ba29bf 100644
--- a/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteTableDetail.test.tsx
@@ -1,13 +1,16 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { screen, cleanup } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import OracleDelete from './mock_data/OracleDelete.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('OracleDelete: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(OracleDelete)
- expect(wrapper).toHaveText('oracle_document_id: 1')
- wrapper.unmount()
+ renderComponent(OracleDelete)
+ expect(screen.getByTestId('oracle-document-id')).toHaveTextContent(
+ `oracle_document_id: 1`,
+ )
})
})
diff --git a/src/containers/shared/components/Transaction/OracleSet/TableDetail.tsx b/src/containers/shared/components/Transaction/OracleSet/TableDetail.tsx
index a65be41d6..16ad02982 100644
--- a/src/containers/shared/components/Transaction/OracleSet/TableDetail.tsx
+++ b/src/containers/shared/components/Transaction/OracleSet/TableDetail.tsx
@@ -12,35 +12,31 @@ export const TableDetail = ({
const { t } = useTranslation()
const language = useLanguage()
return (
- <>
+
{t('oracle_document_id')}:
{tx.oracleDocumentID}
- <>
- {tx.provider && (
- <>
-
{t('provider')}:
-
{tx.provider}
- >
- )}
- {tx.assetClass && (
- <>
-
{t('asset_class')}:
-
{tx.assetClass}
- >
- )}
+ {tx.provider && (
+ <>
+
{t('provider')}:
+
{tx.provider}
+ >
+ )}
+ {tx.assetClass && (
<>
-
{t('last_update_time')}:
-
- {localizeDate(
- new Date(tx.lastUpdateTime * MILLIS_PER_SECOND),
- language,
- DATE_OPTIONS,
- )}
-
+
{t('asset_class')}:
+
{tx.assetClass}
>
- >
+ )}
+
{t('last_update_time')}:
+
+ {localizeDate(
+ new Date(tx.lastUpdateTime * MILLIS_PER_SECOND),
+ language,
+ DATE_OPTIONS,
+ )}
+
{t('trading_pairs')}:
{tx.priceDataSeries.map((priceDataObj, index) => (
@@ -58,6 +54,6 @@ export const TableDetail = ({
>
))}
- >
+
)
}
diff --git a/src/containers/shared/components/Transaction/OracleSet/test/OracleSetSimple.test.tsx b/src/containers/shared/components/Transaction/OracleSet/test/OracleSetSimple.test.tsx
index 033b8d2b2..43b34a7ca 100644
--- a/src/containers/shared/components/Transaction/OracleSet/test/OracleSetSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/OracleSet/test/OracleSetSimple.test.tsx
@@ -1,24 +1,25 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import OracleSet from './mock_data/OracleSet.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('OracleSet: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(OracleSet)
- expectSimpleRowText(wrapper, 'oracle-document-id', '1')
- expectSimpleRowText(wrapper, 'provider', 'provider')
+ renderComponent(OracleSet)
+ expectSimpleRowText(screen, 'oracle-document-id', '1')
+ expectSimpleRowText(screen, 'provider', 'provider')
expectSimpleRowText(
- wrapper,
+ screen,
'last-update-time',
'May 13, 2024 at 9:05:10 PM',
)
- expectSimpleRowText(wrapper, 'asset-class', 'currency')
+ expectSimpleRowText(screen, 'asset-class', 'currency')
expectSimpleRowText(
- wrapper,
+ screen,
'trading-pairs',
'74.2\uE900 XRP/USD1.03BTC/AUDT',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/OracleSet/test/OracleSetTableDetail.test.tsx b/src/containers/shared/components/Transaction/OracleSet/test/OracleSetTableDetail.test.tsx
index 6c8bff213..5622fa5a6 100644
--- a/src/containers/shared/components/Transaction/OracleSet/test/OracleSetTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/OracleSet/test/OracleSetTableDetail.test.tsx
@@ -1,19 +1,20 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import OracleSet from './mock_data/OracleSet.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('OracleDelete: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(OracleSet)
- expect(wrapper).toHaveText(
+ renderComponent(OracleSet)
+ expect(screen.getByTestId('table-detail')).toHaveTextContent(
'oracle_document_id: 1' +
'provider: provider' +
'asset_class: currency' +
'last_update_time: May 13, 2024 at 9:05:10 PM' +
'trading_pairs: 74.2\uE900 XRP/USD, 1.03BTC/AUDT',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/Payment/Simple.tsx b/src/containers/shared/components/Transaction/Payment/Simple.tsx
index 833893ef2..af60c29f8 100644
--- a/src/containers/shared/components/Transaction/Payment/Simple.tsx
+++ b/src/containers/shared/components/Transaction/Payment/Simple.tsx
@@ -29,7 +29,7 @@ export const Simple = (props: TransactionSimpleProps
) => {
)}
{renderPartial()}
@@ -51,7 +51,7 @@ export const Simple = (props: TransactionSimpleProps) => {
-
+
{renderPartial()}
diff --git a/src/containers/shared/components/Transaction/Payment/TableDetail.tsx b/src/containers/shared/components/Transaction/Payment/TableDetail.tsx
index 867566e33..b89268d5e 100644
--- a/src/containers/shared/components/Transaction/Payment/TableDetail.tsx
+++ b/src/containers/shared/components/Transaction/Payment/TableDetail.tsx
@@ -33,7 +33,7 @@ export const TableDetail = ({
{t('to')}
{sourceTag !== undefined && (
-
+
{t('source_tag')}
{': '}
{sourceTag}
diff --git a/src/containers/shared/components/Transaction/Payment/test/PaymentDescription.test.tsx b/src/containers/shared/components/Transaction/Payment/test/PaymentDescription.test.tsx
index fc0fbf80c..d99b5c177 100644
--- a/src/containers/shared/components/Transaction/Payment/test/PaymentDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/Payment/test/PaymentDescription.test.tsx
@@ -1,3 +1,4 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import { Description } from '../Description'
@@ -7,114 +8,104 @@ import mockPaymentDestinationTag from './mock_data/PaymentWithDestinationTag.jso
import mockPaymentPartial from './mock_data/PaymentWithPartial.json'
import mockPaymentSendMax from './mock_data/PaymentWithSendMax.json'
import mockPaymentSourceTag from './mock_data/PaymentWithSourceTag.json'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('Payment: Description', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockPayment)
+ renderComponent(mockPayment)
- expect(wrapper.find('[data-testid="from-to-line"]')).toHaveText(
+ expect(screen.getByTestId('from-to-line')).toHaveTextContent(
`The payment is from rNQEMJA4PsoSrZRn9J6RajAYhcDzzhf8ok to rHoPwMC75KVUhBMeV3uDMybKG5JND74teh`,
)
- expect(wrapper.find('[data-testid="source-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="destination-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.queryByTestId('source-tag-line')).toBeNull()
+ expect(screen.queryByTestId('destination-tag-line')).toBeNull()
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It was instructed to deliver \uE9002,421.8268 XRP`,
)
- expect(wrapper.find('[data-testid="delivered-line"]')).toHaveText(
+ expect(screen.getByTestId('delivered-line')).toHaveTextContent(
`The actual amount delivered was \uE9002,421.8268 XRP`,
)
-
- wrapper.unmount()
})
it('renders with failed partial conversion', () => {
- const wrapper = createWrapper(mockPaymentConvert)
+ renderComponent(mockPaymentConvert)
- expect(wrapper.find('[data-testid="from-to-line"]')).toHaveText(
+ expect(screen.getByTestId('from-to-line')).toHaveTextContent(
`The payment is from r9x5PHDiwuvbpYB3uvGAqEUVV5wxHayQEx to r9x5PHDiwuvbpYB3uvGAqEUVV5wxHayQEx`,
)
- expect(wrapper.find('[data-testid="source-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="destination-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.queryByTestId('source-tag-line')).toBeNull()
+ expect(screen.queryByTestId('destination-tag-line')).toBeNull()
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It was instructed to deliver up to 1,140.00 YCN.r8HgVGenRTAiNSM5iqt9PX2D2EczFZhZr by spending up to \uE9001,140.00 XRP`,
)
- expect(wrapper.find('[data-testid="delivered-line"]')).not.toExist()
-
- wrapper.unmount()
+ expect(screen.queryByTestId('delivered-line')).toBeNull()
})
it('renders with destination tag', () => {
- const wrapper = createWrapper(mockPaymentDestinationTag)
+ renderComponent(mockPaymentDestinationTag)
- expect(wrapper.find('[data-testid="from-to-line"]')).toHaveText(
+ expect(screen.getByTestId('from-to-line')).toHaveTextContent(
`The payment is from rDAE53VfMvftPB4ogpWGWvzkQxfht6JPxr to rHWcuuZoFvDS6gNbmHSdpb7u1hZzxvCoMt`,
)
- expect(wrapper.find('[data-testid="source-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="destination-tag-line"]')).toHaveText(
+ expect(screen.queryByTestId('source-tag-line')).toBeNull()
+ expect(screen.getByTestId('destination-tag-line')).toHaveTextContent(
`The destination tag is 381702`,
)
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It was instructed to deliver \uE9001,531.267 XRP`,
)
- expect(wrapper.find('[data-testid="delivered-line"]')).toHaveText(
+ expect(screen.getByTestId('delivered-line')).toHaveTextContent(
`The actual amount delivered was \uE9001,531.267 XRP`,
)
-
- wrapper.unmount()
})
it('renders with send max', () => {
- const wrapper = createWrapper(mockPaymentSendMax)
+ renderComponent(mockPaymentSendMax)
- expect(wrapper.find('[data-testid="from-to-line"]')).toHaveText(
+ expect(screen.getByTestId('from-to-line')).toHaveTextContent(
`The payment is from r3RaNVLvWjqqtFAawC6jbRhgKyFH7HvRS8 to rprcTynT68nYdKzDTefAZG9HjSHiYcnP4b`,
)
- expect(wrapper.find('[data-testid="destination-tag-line"]')).toHaveText(
+ expect(screen.getByTestId('destination-tag-line')).toHaveTextContent(
`The destination tag is 0`,
)
- expect(wrapper.find('[data-testid="source-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.queryByTestId('source-tag-line')).toBeNull()
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It was instructed to deliver 17,366,599.150289 XRdoge.rLqUC2eCPohYvJCEBJ77eCCqVL2uEiczjA by spending up to 17,366,599.150289 XRdoge.rLqUC2eCPohYvJCEBJ77eCCqVL2uEiczjA`,
)
- expect(wrapper.find('[data-testid="delivered-line"]')).toHaveText(
+ expect(screen.getByTestId('delivered-line')).toHaveTextContent(
`The actual amount delivered was 17,366,599.150289 XRdoge.rLqUC2eCPohYvJCEBJ77eCCqVL2uEiczjA`,
)
- wrapper.unmount()
})
it('renders with partial', () => {
- const wrapper = createWrapper(mockPaymentPartial)
+ renderComponent(mockPaymentPartial)
- expect(wrapper.find('[data-testid="from-to-line"]')).toHaveText(
+ expect(screen.getByTestId('from-to-line')).toHaveTextContent(
`The payment is from rGTurN94Nn3RkJGSqy9MwmQCLpXZkELbnq to rMQ4oGC8fasuJwfdrfknFTttDbf8cR3D2j`,
)
- expect(wrapper.find('[data-testid="destination-tag-line"]')).toHaveText(
+ expect(screen.getByTestId('destination-tag-line')).toHaveTextContent(
`The destination tag is 0`,
)
- expect(wrapper.find('[data-testid="source-tag-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.queryByTestId('source-tag-line')).toBeNull()
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It was instructed to deliver up to 0.001043 xCoin.rXCoYSUnkpygdtfpz3Df8dKQuRZjM9UFi`,
)
- expect(wrapper.find('[data-testid="delivered-line"]')).toHaveText(
+ expect(screen.getByTestId('delivered-line')).toHaveTextContent(
`The actual amount delivered was 0.00104196 xCoin.rXCoYSUnkpygdtfpz3Df8dKQuRZjM9UFi`,
)
-
- wrapper.unmount()
})
it('renders with SourceTag', () => {
- const wrapper = createWrapper(mockPaymentSourceTag)
+ renderComponent(mockPaymentSourceTag)
- expect(wrapper.find('[data-testid="source-tag-line"]')).toHaveText(
+ expect(screen.getByTestId('source-tag-line')).toHaveTextContent(
`The source tag is 20648`,
)
- expect(wrapper.find('[data-testid="destination-tag-line"]')).toHaveText(
+ expect(screen.getByTestId('destination-tag-line')).toHaveTextContent(
`The destination tag is 412453880`,
)
-
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/Payment/test/PaymentSimple.test.tsx b/src/containers/shared/components/Transaction/Payment/test/PaymentSimple.test.tsx
index b05890cde..05e631d5d 100644
--- a/src/containers/shared/components/Transaction/Payment/test/PaymentSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/Payment/test/PaymentSimple.test.tsx
@@ -1,6 +1,7 @@
import { useQuery } from 'react-query'
+import { cleanup, screen } from '@testing-library/react'
import {
- createSimpleWrapperFactory,
+ createSimpleRenderFactory,
expectSimpleRowLabel,
expectSimpleRowText,
} from '../../test'
@@ -18,108 +19,97 @@ jest.mock('react-query', () => ({
useQuery: jest.fn(),
}))
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('Payment: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockPayment)
+ renderComponent(mockPayment)
- expectSimpleRowText(wrapper, 'amount', `\uE9002,421.8268 XRP`)
- expectSimpleRowLabel(wrapper, 'amount', `send`)
+ expectSimpleRowText(screen, 'payment-amount', `\uE9002,421.8268 XRP`)
+ expectSimpleRowLabel(screen, 'payment-amount', `send`)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
`rHoPwMC75KVUhBMeV3uDMybKG5JND74teh`,
)
-
- wrapper.unmount()
})
it('renders with failed partial conversion', () => {
- const wrapper = createWrapper(mockPaymentConvert)
+ renderComponent(mockPaymentConvert)
- expectSimpleRowLabel(wrapper, 'max', `convert_maximum`)
- expectSimpleRowText(wrapper, 'max', `\uE9001,140.00 XRP`)
+ expectSimpleRowLabel(screen, 'max', `convert_maximum`)
+ expectSimpleRowText(screen, 'max', `\uE9001,140.00 XRP`)
- expectSimpleRowLabel(wrapper, 'amount', `convert_to`)
+ expectSimpleRowLabel(screen, 'convert-amount', `convert_to`)
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'convert-amount',
`0.00 YCN.r8HgVGenRTAiNSM5iqt9PX2D2EczFZhZrpartial_payment_allowed`,
)
- expect(wrapper.find('[data-testid="destination"]')).not.toExist()
-
- wrapper.unmount()
+ expect(screen.queryByTestId('destination')).toBeNull()
})
it('renders with destination tag', () => {
- const wrapper = createWrapper(mockPaymentDestinationTag)
+ renderComponent(mockPaymentDestinationTag)
- expectSimpleRowText(wrapper, 'amount', `\uE9001,531.267 XRP`)
- expectSimpleRowLabel(wrapper, 'amount', `send`)
+ expectSimpleRowText(screen, 'payment-amount', `\uE9001,531.267 XRP`)
+ expectSimpleRowLabel(screen, 'payment-amount', `send`)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
`rHWcuuZoFvDS6gNbmHSdpb7u1hZzxvCoMt:381702`,
)
-
- wrapper.unmount()
})
it('renders with send max', () => {
- const wrapper = createWrapper(mockPaymentSendMax)
+ renderComponent(mockPaymentSendMax)
expectSimpleRowText(
- wrapper,
+ screen,
'max',
`17,366,599.150289 XRdoge.rLqUC2eCPohYvJCEBJ77eCCqVL2uEiczjA`,
)
- expectSimpleRowLabel(wrapper, 'max', `using_at_most`)
+ expectSimpleRowLabel(screen, 'max', `using_at_most`)
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'payment-amount',
`17,366,599.150289 XRdoge.rLqUC2eCPohYvJCEBJ77eCCqVL2uEiczjA`,
)
- expectSimpleRowLabel(wrapper, 'amount', `send`)
+ expectSimpleRowLabel(screen, 'payment-amount', `send`)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
`rprcTynT68nYdKzDTefAZG9HjSHiYcnP4b:0`,
)
-
- wrapper.unmount()
})
it('renders with partial', () => {
- const wrapper = createWrapper(mockPaymentPartial)
+ renderComponent(mockPaymentPartial)
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'payment-amount',
`0.00104196 xCoin.rXCoYSUnkpygdtfpz3Df8dKQuRZjM9UFipartial_payment_allowed`,
)
- expectSimpleRowLabel(wrapper, 'amount', `delivered`)
+ expectSimpleRowLabel(screen, 'payment-amount', `delivered`)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
`rMQ4oGC8fasuJwfdrfknFTttDbf8cR3D2j:0`,
)
-
- wrapper.unmount()
})
it('renders with SourceTag', () => {
- const wrapper = createWrapper(mockPaymentSourceTag)
+ renderComponent(mockPaymentSourceTag)
- expectSimpleRowText(wrapper, 'source-tag', `20648`)
-
- wrapper.unmount()
+ expectSimpleRowText(screen, 'source-tag', `20648`)
})
it('renders direct MPT payment', () => {
@@ -132,21 +122,19 @@ describe('Payment: Simple', () => {
data,
}))
- const wrapper = createWrapper(mockPaymentMPT)
+ renderComponent(mockPaymentMPT)
expectSimpleRowText(
- wrapper,
+ screen,
'amount',
`0.1 MPT (000003C31D321B7DDA58324DC38CDF18934FAFFFCDF69D5F)`,
)
- expectSimpleRowLabel(wrapper, 'amount', `send`)
+ expectSimpleRowLabel(screen, 'payment-amount', `send`)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
`rw6UtpfBFaGht6SiC1HpDPNw6Yt25pKvnu`,
)
-
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/Payment/test/PaymentTableDetail.test.tsx b/src/containers/shared/components/Transaction/Payment/test/PaymentTableDetail.test.tsx
index 9f49f0d7f..c9ef98d68 100644
--- a/src/containers/shared/components/Transaction/Payment/test/PaymentTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/Payment/test/PaymentTableDetail.test.tsx
@@ -1,4 +1,5 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import mockPayment from './mock_data/Payment.json'
import mockPaymentConvert from './mock_data/PaymentWithConvert.json'
@@ -7,69 +8,58 @@ import mockPaymentPartial from './mock_data/PaymentWithPartial.json'
import mockPaymentSendMax from './mock_data/PaymentWithSendMax.json'
import mockPaymentSourceTag from './mock_data/PaymentWithSourceTag.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('Payment: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockPayment)
+ const { container } = renderComponent(mockPayment)
// styling makes this look okay
- expect(wrapper.find('.payment')).toHaveText(
+ expect(container).toHaveTextContent(
`send\uE9002,421.8268 XRPtorHoPwMC75KVUhBMeV3uDMybKG5JND74teh`,
)
-
- wrapper.unmount()
})
it('renders with failed partial conversion', () => {
- const wrapper = createWrapper(mockPaymentConvert)
+ const { container } = renderComponent(mockPaymentConvert)
// styling makes this look okay
- expect(wrapper.find('.payment')).toHaveText(
+ expect(container).toHaveTextContent(
`convert_maximum1,140.00 XRPto0.00 YCN.r8HgVGenRTAiNSM5iqt9PX2D2EczFZhZrpartial_payment_allowed`,
)
-
- wrapper.unmount()
})
it('renders with destination tag', () => {
- const wrapper = createWrapper(mockPaymentDestinationTag)
+ const { container } = renderComponent(mockPaymentDestinationTag)
// styling makes this look okay
- expect(wrapper.find('.payment')).toHaveText(
+ expect(container).toHaveTextContent(
`send1,531.267 XRPtorHWcuuZoFvDS6gNbmHSdpb7u1hZzxvCoMt:381702`,
)
-
- wrapper.unmount()
})
it('renders with send max', () => {
- const wrapper = createWrapper(mockPaymentSendMax)
+ const { container } = renderComponent(mockPaymentSendMax)
// styling makes this look okay
- expect(wrapper.find('.payment')).toHaveText(
+ expect(container).toHaveTextContent(
`send17,366,599.150289 XRdoge.rLqUC2eCPohYvJCEBJ77eCCqVL2uEiczjAtorprcTynT68nYdKzDTefAZG9HjSHiYcnP4b:0`,
)
-
- wrapper.unmount()
})
it('renders with partial', () => {
- const wrapper = createWrapper(mockPaymentPartial)
+ const { container } = renderComponent(mockPaymentPartial)
// styling makes this look okay
- expect(wrapper.find('.payment')).toHaveText(
+ expect(container).toHaveTextContent(
`send0.00104196 xCoin.rXCoYSUnkpygdtfpz3Df8dKQuRZjM9UFitorMQ4oGC8fasuJwfdrfknFTttDbf8cR3D2j:0partial_payment_allowed`,
)
-
- wrapper.unmount()
})
it('renders with SourceTag', () => {
- const wrapper = createWrapper(mockPaymentSourceTag)
-
- expect(wrapper.find('.st')).toHaveText('source_tag: 20648')
+ renderComponent(mockPaymentSourceTag)
- wrapper.unmount()
+ expect(screen.getByTestId('st')).toHaveTextContent('source_tag: 20648')
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/Simple.tsx b/src/containers/shared/components/Transaction/PaymentChannelClaim/Simple.tsx
index 890501665..866961a87 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelClaim/Simple.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/Simple.tsx
@@ -26,7 +26,7 @@ export const Simple = ({
return (
<>
{channelAmount && (
-
+
)}
@@ -53,7 +53,11 @@ export const Simple = ({
)}
{channel && (
-
+
{channel}
)}
diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimDescription.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimDescription.test.tsx
index f9cbe4db6..306bf83df 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimDescription.test.tsx
@@ -1,70 +1,68 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createDescriptionWrapperFactory } from '../../test/createWrapperFactory'
+import { createDescriptionRenderFactory } from '../../test/createRenderFactory'
import mockPaymentChannelClaim from './mock_data/PaymentChannelClaim.json'
import mockPaymentChannelClaimClosed from './mock_data/PaymentChannelClaimClosed.json'
import mockPaymentChannelClaimCloseDenied from './mock_data/PaymentChannelClaimCloseDenied.json'
import mockPaymentChannelClaimWithDestinationTag from './mock_data/PaymentChannelClaimWithDestinationTag.json'
import { Description } from '../Description'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('PaymentChannelClaim: Description', () => {
+ afterEach(cleanup)
it('renders a claim', () => {
- const wrapper = createWrapper(mockPaymentChannelClaim)
- expect(wrapper.find('[data-testid="account-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaim)
+ expect(screen.getByTestId('account-line')).toHaveTextContent(
`The transaction was initiated by rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`It will update the payment channel 50107651E7163E294CE0EAD8A20BF7CC046304480FCC9C74A49FFAB3F46FB98E`,
)
- expect(wrapper.find('[data-testid="balance-line"]')).toHaveText(
+ expect(screen.getByTestId('balance-line')).toHaveTextContent(
`The channel balance claimed is \uE90049.65716XRP (increased by \uE9000.01XRP)`,
)
- expect(wrapper.find('[data-testid="closed-line"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('closed-line')).toBeNull()
})
it('renders tx with channel being closed', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimClosed)
- expect(wrapper.find('[data-testid="account-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaimClosed)
+ expect(screen.getByTestId('account-line')).toHaveTextContent(
`The transaction was initiated by rH11fDGhbVH5NVXNXkGAMTmfWhUHjCtA3B`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`It will update the payment channel 3BDB4F92432BCEB2385D3BAA60E8AAEC9B552890A240AEE4AA9E88C9E6C517E8`,
)
- expect(wrapper.find('[data-testid="balance-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="closed-line"]')).toHaveText(
+ expect(screen.queryByTestId('balance-line')).toBeNull()
+ expect(screen.getByTestId('closed-line')).toHaveTextContent(
`The payment channel will be closed, any remaining balance will be returned to the source account`,
)
- wrapper.unmount()
})
it('renders tx requesting channel be closed but not closing it', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimCloseDenied)
- expect(wrapper.find('[data-testid="account-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaimCloseDenied)
+ expect(screen.getByTestId('account-line')).toHaveTextContent(
`The transaction was initiated by rH11fDGhbVH5NVXNXkGAMTmfWhUHjCtA3B`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`It will update the payment channel 3BDB4F92432BCEB2385D3BAA60E8AAEC9B552890A240AEE4AA9E88C9E6C517E8`,
)
- expect(wrapper.find('[data-testid="balance-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="closed-line"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('balance-line')).toBeNull()
+ expect(screen.queryByTestId('closed-line')).toBeNull()
})
it('renders tx with destination tag', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimWithDestinationTag)
- expect(wrapper.find('[data-testid="account-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaimWithDestinationTag)
+ expect(screen.getByTestId('account-line')).toHaveTextContent(
`The transaction was initiated by rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`It will update the payment channel 5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3`,
)
- expect(wrapper.find('[data-testid="balance-line"]')).toHaveText(
+ expect(screen.getByTestId('balance-line')).toHaveTextContent(
`The channel balance claimed is \uE9001.00XRP (increased by \uE9001.00XRP)`,
)
- expect(wrapper.find('[data-testid="closed-line"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('closed-line')).toBeNull()
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimSimple.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimSimple.test.tsx
index 4a54173bf..63ecc2891 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimSimple.test.tsx
@@ -1,6 +1,7 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockPaymentChannelClaim from './mock_data/PaymentChannelClaim.json'
import mockPaymentChannelClaimClosed from './mock_data/PaymentChannelClaimClosed.json'
@@ -12,112 +13,109 @@ import {
expectSimpleRowText,
} from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('PaymentChannelClaim: Simple', () => {
+ afterEach(cleanup)
it('renders a claim', () => {
- const wrapper = createWrapper(mockPaymentChannelClaim)
- expectSimpleRowLabel(wrapper, 'amount', 'channel amount')
- expectSimpleRowText(wrapper, 'amount', '\uE90070.00 XRP')
- expectSimpleRowLabel(wrapper, 'claimed', 'amount claimed')
- expectSimpleRowText(wrapper, 'claimed', '\uE9000.01 XRP')
- expectSimpleRowLabel(wrapper, 'total', 'total claimed')
- expectSimpleRowText(wrapper, 'total', '\uE90049.65716 XRP')
- expectSimpleRowLabel(wrapper, 'source', 'source')
+ renderComponent(mockPaymentChannelClaim)
+ expectSimpleRowLabel(screen, 'channel-amount', 'channel amount')
+ expectSimpleRowText(screen, 'channel-amount', '\uE90070.00 XRP')
+ expectSimpleRowLabel(screen, 'claimed', 'amount claimed')
+ expectSimpleRowText(screen, 'claimed', '\uE9000.01 XRP')
+ expectSimpleRowLabel(screen, 'total', 'total claimed')
+ expectSimpleRowText(screen, 'total', '\uE90049.65716 XRP')
+ expectSimpleRowLabel(screen, 'source', 'source')
expectSimpleRowText(
- wrapper,
+ screen,
'source',
'rnNzy3iPc7gPEAJbAdXwxY1UTBamBqTYhR:1002539517',
)
- expectSimpleRowLabel(wrapper, 'destination', 'destination')
+ expectSimpleRowLabel(screen, 'destination', 'destination')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
- expectSimpleRowLabel(wrapper, '.channel', 'Channel ID')
+ expectSimpleRowLabel(screen, 'channel', 'Channel ID')
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'50107651E7163E294CE0EAD8A20BF7CC046304480FCC9C74A49FFAB3F46FB98E',
)
- expectSimpleRowNotToExist(wrapper, 'renew')
- expectSimpleRowNotToExist(wrapper, 'close-request')
- expectSimpleRowNotToExist(wrapper, 'closed')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'renew')
+ expectSimpleRowNotToExist(screen, 'close-request')
+ expectSimpleRowNotToExist(screen, 'closed')
})
it('renders tx with channel being closed', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimClosed)
- expectSimpleRowText(wrapper, 'amount', '\uE90010.00 XRP')
- expectSimpleRowNotToExist(wrapper, 'claimed')
- expectSimpleRowText(wrapper, 'total', '\uE9000.34 XRP')
+ renderComponent(mockPaymentChannelClaimClosed)
+ expectSimpleRowText(screen, 'channel-amount', '\uE90010.00 XRP')
+ expectSimpleRowNotToExist(screen, 'claimed')
+ expectSimpleRowText(screen, 'total', '\uE9000.34 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'source',
'rH11fDGhbVH5NVXNXkGAMTmfWhUHjCtA3B:2647131528',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'3BDB4F92432BCEB2385D3BAA60E8AAEC9B552890A240AEE4AA9E88C9E6C517E8',
)
- expectSimpleRowNotToExist(wrapper, 'renew')
- expectSimpleRowText(wrapper, 'close-request', 'close channel request')
- expectSimpleRowText(wrapper, 'closed', 'payment channel closed')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'renew')
+ expectSimpleRowText(screen, 'close-request', 'close channel request')
+ expectSimpleRowText(screen, 'closed', 'payment channel closed')
})
it('renders tx requesting channel be closed but not closing it', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimCloseDenied)
- expectSimpleRowText(wrapper, 'amount', '\uE90010.00 XRP')
- expectSimpleRowNotToExist(wrapper, 'claimed')
- expectSimpleRowNotToExist(wrapper, 'total')
+ renderComponent(mockPaymentChannelClaimCloseDenied)
+ expectSimpleRowText(screen, 'channel-amount', '\uE90010.00 XRP')
+ expectSimpleRowNotToExist(screen, 'claimed')
+ expectSimpleRowNotToExist(screen, 'total')
expectSimpleRowText(
- wrapper,
+ screen,
'source',
'rH11fDGhbVH5NVXNXkGAMTmfWhUHjCtA3B:2647131528',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'3BDB4F92432BCEB2385D3BAA60E8AAEC9B552890A240AEE4AA9E88C9E6C517E8',
)
- expectSimpleRowNotToExist(wrapper, 'renew')
- expectSimpleRowText(wrapper, 'close-request', 'close channel request')
- expectSimpleRowNotToExist(wrapper, 'closed')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'renew')
+ expectSimpleRowText(screen, 'close-request', 'close channel request')
+ expectSimpleRowNotToExist(screen, 'closed')
})
it('renders tx with destination tag', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimWithDestinationTag)
- expectSimpleRowText(wrapper, 'amount', '\uE900100.00 XRP')
- expectSimpleRowText(wrapper, 'claimed', '\uE9001.00 XRP')
- expectSimpleRowText(wrapper, 'total', '\uE9001.00 XRP')
- expectSimpleRowText(wrapper, 'source', 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH')
+ renderComponent(mockPaymentChannelClaimWithDestinationTag)
+ expectSimpleRowText(screen, 'channel-amount', '\uE900100.00 XRP')
+ expectSimpleRowText(screen, 'claimed', '\uE9001.00 XRP')
+ expectSimpleRowText(screen, 'total', '\uE9001.00 XRP')
+ expectSimpleRowText(screen, 'source', 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn:20170428',
)
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3',
)
- expectSimpleRowNotToExist(wrapper, 'renew')
- expectSimpleRowNotToExist(wrapper, 'close-request')
- expectSimpleRowNotToExist(wrapper, 'closed')
- wrapper.unmount()
+ expectSimpleRowNotToExist(screen, 'renew')
+ expectSimpleRowNotToExist(screen, 'close-request')
+ expectSimpleRowNotToExist(screen, 'closed')
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimTableDetail.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimTableDetail.test.tsx
index de68e843d..b8eeba01b 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelClaim/test/PaymentChannelClaimTableDetail.test.tsx
@@ -1,90 +1,88 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createTableDetailWrapperFactory } from '../../test/createWrapperFactory'
+import { createTableDetailRenderFactory } from '../../test/createRenderFactory'
import { TableDetail } from '../TableDetail'
import mockPaymentChannelClaim from './mock_data/PaymentChannelClaim.json'
import mockPaymentChannelClaimClosed from './mock_data/PaymentChannelClaimClosed.json'
import mockPaymentChannelClaimCloseDenied from './mock_data/PaymentChannelClaimCloseDenied.json'
import mockPaymentChannelClaimWithDestinationTag from './mock_data/PaymentChannelClaimWithDestinationTag.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail, i18n)
+const renderComponent = createTableDetailRenderFactory(TableDetail, i18n)
describe('PaymentChannelClaim: TableDetail', () => {
+ afterEach(cleanup)
it('renders a claim', () => {
- const wrapper = createWrapper(mockPaymentChannelClaim)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaim)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcernNzy3iPc7gPEAJbAdXwxY1UTBamBqTYhR:1002539517',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
- expect(wrapper.find('[data-testid="claimed"]')).toHaveText(
+ expect(screen.getByTestId('claimed')).toHaveTextContent(
'claimed\uE9000.01 XRP (\uE90020.34284 XRP of \uE90070.00 XRP remaining)',
)
- expect(wrapper.find('[data-testid="channel-amount"]')).not.toExist()
- expect(wrapper.find('[data-testid="renew"]')).not.toExist()
- expect(wrapper.find('[data-testid="close-request"]')).not.toExist()
- expect(wrapper.find('[data-testid="closed"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('channel-amount')).toBeNull()
+ expect(screen.queryByTestId('renew')).toBeNull()
+ expect(screen.queryByTestId('close-request')).toBeNull()
+ expect(screen.queryByTestId('closed')).toBeNull()
})
it('renders tx with channel being closed', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimClosed)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaimClosed)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcerH11fDGhbVH5NVXNXkGAMTmfWhUHjCtA3B:2647131528',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
- expect(wrapper.find('[data-testid="claimed"]')).not.toExist()
- expect(wrapper.find('[data-testid="channel-amount"]')).toHaveText(
+ expect(screen.queryByTestId('claimed')).toBeNull()
+ expect(screen.getByTestId('channel-amount')).toHaveTextContent(
'channel amount\uE90010.00 XRP',
)
- expect(wrapper.find('[data-testid="renew"]')).not.toExist()
- expect(wrapper.find('[data-testid="close-request"]')).toHaveText(
+ expect(screen.queryByTestId('renew')).toBeNull()
+ expect(screen.getByTestId('close-request')).toHaveTextContent(
'close channel request',
)
- expect(wrapper.find('[data-testid="closed"]')).toHaveText(
+ expect(screen.getByTestId('closed')).toHaveTextContent(
'payment channel closed',
)
- wrapper.unmount()
})
it('renders tx requesting channel be closed but not closing it', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimCloseDenied)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaimCloseDenied)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcerH11fDGhbVH5NVXNXkGAMTmfWhUHjCtA3B:2647131528',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
- expect(wrapper.find('[data-testid="claimed"]')).not.toExist()
- expect(wrapper.find('[data-testid="channel-amount"]')).toHaveText(
+ expect(screen.queryByTestId('claimed')).toBeNull()
+ expect(screen.getByTestId('channel-amount')).toHaveTextContent(
'channel amount\uE90010.00 XRP',
)
- expect(wrapper.find('[data-testid="renew"]')).not.toExist()
- expect(wrapper.find('[data-testid="close-request"]')).toHaveText(
+ expect(screen.queryByTestId('renew')).toBeNull()
+ expect(screen.getByTestId('close-request')).toHaveTextContent(
'close channel request',
)
- expect(wrapper.find('[data-testid="closed"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('closed')).toBeNull()
})
it('renders tx with destination tag', () => {
- const wrapper = createWrapper(mockPaymentChannelClaimWithDestinationTag)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelClaimWithDestinationTag)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcerN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn:20170428',
)
- expect(wrapper.find('[data-testid="claimed"]')).toHaveText(
+ expect(screen.getByTestId('claimed')).toHaveTextContent(
'claimed\uE9001.00 XRP (\uE90099.00 XRP of \uE900100.00 XRP remaining)',
)
- expect(wrapper.find('[data-testid="channel-amount"]')).not.toExist()
- expect(wrapper.find('[data-testid="renew"]')).not.toExist()
- expect(wrapper.find('[data-testid="close-request"]')).not.toExist()
- expect(wrapper.find('[data-testid="closed"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('channel-amount')).toBeNull()
+ expect(screen.queryByTestId('renew')).toBeNull()
+ expect(screen.queryByTestId('close-request')).toBeNull()
+ expect(screen.queryByTestId('closed')).toBeNull()
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/Simple.tsx b/src/containers/shared/components/Transaction/PaymentChannelCreate/Simple.tsx
index ab3a8717f..b91f8426c 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelCreate/Simple.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/Simple.tsx
@@ -18,7 +18,7 @@ export const Simple = ({
return (
<>
-
+
@@ -39,7 +39,11 @@ export const Simple = ({
)}
{channel && (
-
+
{channel}
)}
diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/TableDetail.tsx b/src/containers/shared/components/Transaction/PaymentChannelCreate/TableDetail.tsx
index bca200507..ca7cb2ac4 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelCreate/TableDetail.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/TableDetail.tsx
@@ -20,7 +20,7 @@ export const TableDetail = ({
{t('destination')}
-
+
diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateDescription.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateDescription.test.tsx
index bba8fc3b9..0e5c89c56 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateDescription.test.tsx
@@ -1,63 +1,62 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
import mockPaymentChannelCreate from './mock_data/PaymentChannelCreate.json'
import mockPaymentChannelCreateFailed from './mock_data/PaymentChannelCreateFailed.json'
import mockPaymentChannelCreateWithDestinationTag from './mock_data/PaymentChannelCreateWithDestinationTag.json'
import { Description } from '../Description'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('PaymentChannelCreate: Description', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockPaymentChannelCreate)
- expect(wrapper.find('[data-testid="accounts-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelCreate)
+ expect(screen.getByTestId('accounts-line')).toHaveTextContent(
`The account rJnQrhRTXutuSwtrwxYiTkHn4Dtp8sF2LM:2460331042 will create a payment channel to rUXYat4hW2M87gHoqKK7fC4cqrT9C6V7d7`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`The channel ID is 15AB9EE9344C42C05164E6A1F2F08B35F35D7B9D66CCB9697452B0995C8F8242`,
)
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`The channel amount is \uE9001.00 XRP`,
)
- expect(wrapper.find('[data-testid="delay-line"]')).toHaveText(
+ expect(screen.getByTestId('delay-line')).toHaveTextContent(
`The channel has a settlement delay of 3,600 seconds`,
)
- expect(wrapper.find('[data-testid="cancel-line"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('cancel-line')).toBeNull()
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockPaymentChannelCreateFailed)
- expect(wrapper.find('[data-testid="accounts-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelCreateFailed)
+ expect(screen.getByTestId('accounts-line')).toHaveTextContent(
`The account rMphibGfHpLDU4DzVCspzLYVuMNpmzN6n8:2810223114 will create a payment channel to rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).not.toExist()
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.queryByTestId('channel-line')).toBeNull()
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`The channel amount is \uE90010.00 XRP`,
)
- expect(wrapper.find('[data-testid="delay-line"]')).toHaveText(
+ expect(screen.getByTestId('delay-line')).toHaveTextContent(
`The channel has a settlement delay of 3,600 seconds`,
)
- expect(wrapper.find('[data-testid="cancel-line"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('cancel-line')).toBeNull()
})
it('renders tx with destination tag', () => {
- const wrapper = createWrapper(mockPaymentChannelCreateWithDestinationTag)
- expect(wrapper.find('[data-testid="accounts-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelCreateWithDestinationTag)
+ expect(screen.getByTestId('accounts-line')).toHaveTextContent(
`The account rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH will create a payment channel to rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn:20170428`,
)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`The channel ID is 5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3`,
)
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`The channel amount is \uE900100.00 XRP`,
)
- expect(wrapper.find('[data-testid="delay-line"]')).toHaveText(
+ expect(screen.getByTestId('delay-line')).toHaveTextContent(
`The channel has a settlement delay of 86,400 seconds`,
)
- expect(wrapper.find('[data-testid="cancel-line"]')).not.toExist()
- wrapper.unmount()
+ expect(screen.queryByTestId('cancel-line')).toBeNull()
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateSimple.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateSimple.test.tsx
index c8bae3e9d..4330870e7 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateSimple.test.tsx
@@ -1,7 +1,8 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import {
- createSimpleWrapperFactory,
+ createSimpleRenderFactory,
expectSimpleRowLabel,
expectSimpleRowNotToExist,
expectSimpleRowText,
@@ -11,69 +12,67 @@ import mockPaymentChannelCreateFailed from './mock_data/PaymentChannelCreateFail
import mockPaymentChannelCreateWithDestinationTag from './mock_data/PaymentChannelCreateWithDestinationTag.json'
import { Simple } from '../Simple'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('PaymentChannelCreate: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockPaymentChannelCreate)
- expectSimpleRowLabel(wrapper, 'amount', 'Amount')
- expectSimpleRowText(wrapper, 'amount', '\uE9001.00 XRP')
- expectSimpleRowLabel(wrapper, 'source', 'source')
+ renderComponent(mockPaymentChannelCreate)
+ expectSimpleRowLabel(screen, 'channel-amount', 'Amount')
+ expectSimpleRowText(screen, 'channel-amount', '\uE9001.00 XRP')
+ expectSimpleRowLabel(screen, 'source', 'source')
expectSimpleRowText(
- wrapper,
+ screen,
'source',
'rJnQrhRTXutuSwtrwxYiTkHn4Dtp8sF2LM:2460331042',
)
- expectSimpleRowLabel(wrapper, 'destination', 'destination')
+ expectSimpleRowLabel(screen, 'destination', 'destination')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rUXYat4hW2M87gHoqKK7fC4cqrT9C6V7d7',
)
- expectSimpleRowLabel(wrapper, 'delay', 'Settlement Delay')
- expectSimpleRowText(wrapper, 'delay', '3,600 sec.')
- expectSimpleRowLabel(wrapper, '.channel', 'Channel ID')
+ expectSimpleRowLabel(screen, 'delay', 'Settlement Delay')
+ expectSimpleRowText(screen, 'delay', '3,600 sec.')
+ expectSimpleRowLabel(screen, 'channel', 'Channel ID')
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'15AB9EE9344C42C05164E6A1F2F08B35F35D7B9D66CCB9697452B0995C8F8242',
)
- wrapper.unmount()
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockPaymentChannelCreateFailed)
- expectSimpleRowText(wrapper, 'amount', '\uE90010.00 XRP')
+ renderComponent(mockPaymentChannelCreateFailed)
+ expectSimpleRowText(screen, 'channel-amount', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'source',
'rMphibGfHpLDU4DzVCspzLYVuMNpmzN6n8:2810223114',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
- expectSimpleRowText(wrapper, 'delay', '3,600 sec.')
- expectSimpleRowNotToExist(wrapper, '.channel')
- wrapper.unmount()
+ expectSimpleRowText(screen, 'delay', '3,600 sec.')
+ expectSimpleRowNotToExist(screen, 'channel')
})
it('renders tx with destination tag', () => {
- const wrapper = createWrapper(mockPaymentChannelCreateWithDestinationTag)
- expectSimpleRowText(wrapper, 'amount', '\uE900100.00 XRP')
- expectSimpleRowText(wrapper, 'source', 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH')
+ renderComponent(mockPaymentChannelCreateWithDestinationTag)
+ expectSimpleRowText(screen, 'channel-amount', '\uE900100.00 XRP')
+ expectSimpleRowText(screen, 'source', 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn:20170428',
)
- expectSimpleRowText(wrapper, 'delay', '86,400 sec.')
+ expectSimpleRowText(screen, 'delay', '86,400 sec.')
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'5DB01B7FFED6B67E6B0414DED11E051D2EE2B7619CE0EAA6286D67A3A4D5BDB3',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateTableDetail.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateTableDetail.test.tsx
index bef431ba4..2b16ad052 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelCreate/test/PaymentChannelCreateTableDetail.test.tsx
@@ -1,49 +1,52 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createTableDetailWrapperFactory } from '../../test'
+import { createTableDetailRenderFactory } from '../../test'
import mockPaymentChannelCreate from './mock_data/PaymentChannelCreate.json'
import mockPaymentChannelCreateFailed from './mock_data/PaymentChannelCreateFailed.json'
import mockPaymentChannelCreateWithDestinationTag from './mock_data/PaymentChannelCreateWithDestinationTag.json'
import { TableDetail } from '../TableDetail'
-const createWrapper = createTableDetailWrapperFactory(TableDetail, i18n)
+const renderComponent = createTableDetailRenderFactory(TableDetail, i18n)
describe('PaymentChannelCreate: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockPaymentChannelCreate)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelCreate)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcerJnQrhRTXutuSwtrwxYiTkHn4Dtp8sF2LM:2460331042',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrUXYat4hW2M87gHoqKK7fC4cqrT9C6V7d7',
)
- expect(wrapper.find('[data-testid="amount"]')).toHaveText('\uE9001.00 XRP')
- wrapper.unmount()
+ expect(screen.getByTestId('channel-amount')).toHaveTextContent(
+ 'channel amount\uE9001.00 XRP',
+ )
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockPaymentChannelCreateFailed)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelCreateFailed)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcerMphibGfHpLDU4DzVCspzLYVuMNpmzN6n8:2810223114',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN',
)
- expect(wrapper.find('[data-testid="amount"]')).toHaveText('\uE90010.00 XRP')
- wrapper.unmount()
+ expect(screen.getByTestId('channel-amount')).toHaveTextContent(
+ 'channel amount\uE90010.00 XRP',
+ )
})
it('renders tx with destination tag', () => {
- const wrapper = createWrapper(mockPaymentChannelCreateWithDestinationTag)
- expect(wrapper.find('[data-testid="source"]')).toHaveText(
+ renderComponent(mockPaymentChannelCreateWithDestinationTag)
+ expect(screen.getByTestId('source')).toHaveTextContent(
'sourcerN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
)
- expect(wrapper.find('[data-testid="destination"]')).toHaveText(
+ expect(screen.getByTestId('destination')).toHaveTextContent(
'destinationrf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn:20170428',
)
- expect(wrapper.find('[data-testid="amount"]')).toHaveText(
- '\uE900100.00 XRP',
+ expect(screen.getByTestId('channel-amount')).toHaveTextContent(
+ 'channel amount\uE900100.00 XRP',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelFund/Simple.tsx b/src/containers/shared/components/Transaction/PaymentChannelFund/Simple.tsx
index a1111c43c..f5773a0a0 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelFund/Simple.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelFund/Simple.tsx
@@ -46,7 +46,11 @@ export const Simple = ({
)}
{channel && (
-
+
{channel}
)}
diff --git a/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundDescription.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundDescription.test.tsx
index ae1fdc448..ad60c7d74 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundDescription.test.tsx
@@ -1,32 +1,32 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createDescriptionWrapperFactory } from '../../test/createWrapperFactory'
+import { createDescriptionRenderFactory } from '../../test/createRenderFactory'
import mockPaymentChannelFund from './mock_data/PaymentChannelFund.json'
import mockPaymentChannelFundFailed from './mock_data/PaymentChannelFundFailed.json'
import { Description } from '../Description'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('PaymentChannelFund: Description', () => {
+ afterEach(cleanup)
it('renders a Fund', () => {
- const wrapper = createWrapper(mockPaymentChannelFund)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelFund)
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`It will update the payment channel 4BEAC9E4C10674AB698EAC0F2D78A4FF507428370578A59B04883E7EB8D82260`,
)
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It will increase the channel amount by \uE9001.00 XRP from \uE90074.00 XRP to \uE90075.00 XRP`,
)
- wrapper.unmount()
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockPaymentChannelFundFailed)
- expect(wrapper.find('[data-testid="channel-line"]')).toHaveText(
+ renderComponent(mockPaymentChannelFundFailed)
+ expect(screen.getByTestId('channel-line')).toHaveTextContent(
`It will update the payment channel 933F93F7113A2F94B7838D64D0D2A244C57EFD6411C16FFF5FA293D200EF5876`,
)
- expect(wrapper.find('[data-testid="amount-line"]')).toHaveText(
+ expect(screen.getByTestId('amount-line')).toHaveTextContent(
`It will increase the channel amount by \uE90020.00 XRP`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundSimple.test.tsx b/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundSimple.test.tsx
index a9b884ad6..01d2f856f 100644
--- a/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/PaymentChannelFund/test/PaymentChannelFundSimple.test.tsx
@@ -1,6 +1,7 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockPaymentChannelFund from './mock_data/PaymentChannelFund.json'
import mockPaymentChannelFundFailed from './mock_data/PaymentChannelFundFailed.json'
@@ -10,52 +11,51 @@ import {
expectSimpleRowText,
} from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('PaymentChannelFund: Simple', () => {
+ afterEach(cleanup)
it('renders a fund', () => {
- const wrapper = createWrapper(mockPaymentChannelFund)
- expectSimpleRowLabel(wrapper, 'increase', 'channel amount increase')
- expectSimpleRowText(wrapper, 'increase', '+\uE9001.00 XRP')
- expectSimpleRowLabel(wrapper, 'channel-amount', 'channel amount')
- expectSimpleRowText(wrapper, 'channel-amount', '\uE90075.00 XRP')
- expectSimpleRowLabel(wrapper, 'total', 'total claimed')
- expectSimpleRowText(wrapper, 'total', '\uE90061.859345 XRP')
- expectSimpleRowLabel(wrapper, 'source', 'source')
+ renderComponent(mockPaymentChannelFund)
+ expectSimpleRowLabel(screen, 'increase', 'channel amount increase')
+ expectSimpleRowText(screen, 'increase', '+\uE9001.00 XRP')
+ expectSimpleRowLabel(screen, 'channel-amount', 'channel amount')
+ expectSimpleRowText(screen, 'channel-amount', '\uE90075.00 XRP')
+ expectSimpleRowLabel(screen, 'total', 'total claimed')
+ expectSimpleRowText(screen, 'total', '\uE90061.859345 XRP')
+ expectSimpleRowLabel(screen, 'source', 'source')
expectSimpleRowText(
- wrapper,
+ screen,
'source',
'rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN:3839231768',
)
- expectSimpleRowLabel(wrapper, 'destination', 'destination')
+ expectSimpleRowLabel(screen, 'destination', 'destination')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rBFpf3YQQrcR1HnCt5AhYpNVvXUh4W89Dr',
)
- expectSimpleRowLabel(wrapper, '.channel', 'Channel ID')
+ expectSimpleRowLabel(screen, 'channel', 'Channel ID')
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'4BEAC9E4C10674AB698EAC0F2D78A4FF507428370578A59B04883E7EB8D82260',
)
- wrapper.unmount()
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockPaymentChannelFundFailed)
- expectSimpleRowLabel(wrapper, 'increase', 'channel amount increase')
- expectSimpleRowText(wrapper, 'increase', '+\uE90020.00 XRP')
- expectSimpleRowNotToExist(wrapper, 'channel-amount')
- expectSimpleRowNotToExist(wrapper, 'total')
- expectSimpleRowNotToExist(wrapper, 'source')
- expectSimpleRowNotToExist(wrapper, 'destination')
- expectSimpleRowNotToExist(wrapper, 'source')
+ renderComponent(mockPaymentChannelFundFailed)
+ expectSimpleRowLabel(screen, 'increase', 'channel amount increase')
+ expectSimpleRowText(screen, 'increase', '+\uE90020.00 XRP')
+ expectSimpleRowNotToExist(screen, 'channel-amount')
+ expectSimpleRowNotToExist(screen, 'total')
+ expectSimpleRowNotToExist(screen, 'source')
+ expectSimpleRowNotToExist(screen, 'destination')
+ expectSimpleRowNotToExist(screen, 'source')
expectSimpleRowText(
- wrapper,
- '.channel',
+ screen,
+ 'channel',
'933F93F7113A2F94B7838D64D0D2A244C57EFD6411C16FFF5FA293D200EF5876',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/SetFee/test/SetFeeDescription.test.tsx b/src/containers/shared/components/Transaction/SetFee/test/SetFeeDescription.test.tsx
index db2c1c14b..ac21f943f 100644
--- a/src/containers/shared/components/Transaction/SetFee/test/SetFeeDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/SetFee/test/SetFeeDescription.test.tsx
@@ -1,37 +1,37 @@
-import { createDescriptionWrapperFactory } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createDescriptionRenderFactory } from '../../test'
import { Description } from '../Description'
import i18nTestConfigEnUS from '../../../../../../i18n/testConfigEnglish'
import SetFeePreAmendment from './mock_data/SetFee_PreAmendment.json'
import SetFeePostAmendment from './mock_data/SetFee_PostAmendment.json'
-const createWrapper = createDescriptionWrapperFactory(
+const renderComponent = createDescriptionRenderFactory(
Description,
i18nTestConfigEnUS,
)
-function testDescription(wrapper) {
- expect(wrapper.find('[data-testid="fees-line"]')).toHaveText(
+function testDescription() {
+ expect(screen.getByTestId('fees-line')).toHaveTextContent(
`Future transactions will require a minimum fee of \uE9000.00001 XRP.`,
)
- expect(wrapper.find('[data-testid="reserves-line"]')).toHaveText(
+ expect(screen.getByTestId('reserves-line')).toHaveTextContent(
`Accounts must now hold a base of \uE90010.00 XRP and an additional \uE9002.00 XRP for each additional object that account owns.`,
)
- expect(wrapper.find('[data-testid="documentation-line"]')).toHaveText(
+ expect(screen.getByTestId('documentation-line')).toHaveTextContent(
`Visit the docs: Fees`,
)
}
describe('SetFee: Description', () => {
+ afterEach(cleanup)
it('renders Description for transaction before XRPFees amendment', () => {
- const wrapper = createWrapper(SetFeePreAmendment)
- testDescription(wrapper)
- wrapper.unmount()
+ renderComponent(SetFeePreAmendment)
+ testDescription()
})
it('renders Description for transaction after XRPFees amendment', () => {
- const wrapper = createWrapper(SetFeePostAmendment)
- testDescription(wrapper)
- wrapper.unmount()
+ renderComponent(SetFeePostAmendment)
+ testDescription()
})
})
diff --git a/src/containers/shared/components/Transaction/SetFee/test/SetFeeSimple.test.tsx b/src/containers/shared/components/Transaction/SetFee/test/SetFeeSimple.test.tsx
index df3921f9f..b99a0a3a7 100644
--- a/src/containers/shared/components/Transaction/SetFee/test/SetFeeSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/SetFee/test/SetFeeSimple.test.tsx
@@ -1,5 +1,6 @@
+import { cleanup, screen } from '@testing-library/react'
import {
- createSimpleWrapperFactory,
+ createSimpleRenderFactory,
expectSimpleRowLabel,
expectSimpleRowText,
} from '../../test'
@@ -9,27 +10,26 @@ import i18nTestConfigEnUS from '../../../../../../i18n/testConfigEnglish'
import SetFeePreAmendment from './mock_data/SetFee_PreAmendment.json'
import SetFeePostAmendment from './mock_data/SetFee_PostAmendment.json'
-const createWrapper = createSimpleWrapperFactory(Simple, i18nTestConfigEnUS)
+const renderComponent = createSimpleRenderFactory(Simple, i18nTestConfigEnUS)
-function testSimple(wrapper) {
- expectSimpleRowLabel(wrapper, `base-fee`, 'Base Fee')
- expectSimpleRowText(wrapper, `base-fee`, `\uE9000.00001 XRP`)
- expectSimpleRowLabel(wrapper, `reserve`, 'Reserve')
- expectSimpleRowText(wrapper, `reserve`, `\uE90010.00 XRP`)
- expectSimpleRowLabel(wrapper, `reserve-increment`, 'Reserve Increment')
- expectSimpleRowText(wrapper, `reserve-increment`, `\uE9002.00 XRP`)
+function testSimple() {
+ expectSimpleRowLabel(screen, `base-fee`, 'Base Fee')
+ expectSimpleRowText(screen, `base-fee`, `\uE9000.00001 XRP`)
+ expectSimpleRowLabel(screen, `reserve`, 'Reserve')
+ expectSimpleRowText(screen, `reserve`, `\uE90010.00 XRP`)
+ expectSimpleRowLabel(screen, `reserve-increment`, 'Reserve Increment')
+ expectSimpleRowText(screen, `reserve-increment`, `\uE9002.00 XRP`)
}
describe('SetFee: Simple', () => {
+ afterEach(cleanup)
it('renders Simple for transaction before XRPFees amendment', () => {
- const wrapper = createWrapper(SetFeePreAmendment)
- testSimple(wrapper)
- wrapper.unmount()
+ renderComponent(SetFeePreAmendment)
+ testSimple()
})
it('renders Simple for transaction after XRPFees amendment', () => {
- const wrapper = createWrapper(SetFeePostAmendment)
- testSimple(wrapper)
- wrapper.unmount()
+ renderComponent(SetFeePostAmendment)
+ testSimple()
})
})
diff --git a/src/containers/shared/components/Transaction/SetHook/Simple.tsx b/src/containers/shared/components/Transaction/SetHook/Simple.tsx
index b4c38dfe1..732940b09 100644
--- a/src/containers/shared/components/Transaction/SetHook/Simple.tsx
+++ b/src/containers/shared/components/Transaction/SetHook/Simple.tsx
@@ -25,12 +25,14 @@ export const Simple = ({
)}
{hook.HookGrants && (
-
+
{hook.HookGrants.map((hookGrant) => {
const grant = hookGrant.HookGrant
return (
-
-
{grant.HookHash}
+
+
+ {grant.HookHash}
+
{grant.Authorize &&
}
)
diff --git a/src/containers/shared/components/Transaction/SetHook/test/SetHookSimple.test.tsx b/src/containers/shared/components/Transaction/SetHook/test/SetHookSimple.test.tsx
index 164d6a026..bfb7a5eb4 100644
--- a/src/containers/shared/components/Transaction/SetHook/test/SetHookSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/SetHook/test/SetHookSimple.test.tsx
@@ -1,101 +1,107 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen, within } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockSetHook from './mock_data/SetHook.json'
import mockSetHook2 from './mock_data/SetHook2.json'
import mockSetHookFailure from './mock_data/SetHookFailure.json'
import { expectSimpleRowText } from '../../test/expectations'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('SetHookSimple', () => {
+describe('SetHook: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockSetHook)
+ renderComponent(mockSetHook)
- expect(wrapper.find('.group')).toHaveLength(2)
+ expect(screen.getAllByTestId('group')).toHaveLength(2)
- const hook1 = wrapper.find('.group').at(0)
- const hook2 = wrapper.find('.group').at(1)
+ const hook1 = screen.getAllByTestId('group')[0]
+ const hook2 = screen.getAllByTestId('group')[1]
expectSimpleRowText(
- hook1,
+ within(hook1),
'hook-hash',
'4E57C7FE7A84ABFA53CFE411DE9BA3420B94F55038BF238EBE1EB89095ABA4DE',
)
- expectSimpleRowText(hook1, 'hook-on', 'Invoke')
+ expectSimpleRowText(within(hook1), 'hook-on', 'Invoke')
expectSimpleRowText(
- hook1,
+ within(hook1),
'hook-namespace',
'0000000000000000000000000000000000000000000000000000000000000000',
)
- expectSimpleRowText(hook1, 'hook-flags', 'hsfOverride')
- expectSimpleRowText(hook1, 'hook-api-version', '0')
+ expectSimpleRowText(within(hook1), 'hook-flags', 'hsfOverride')
+ expectSimpleRowText(within(hook1), 'hook-api-version', '0')
expectSimpleRowText(
- hook2,
+ within(hook2),
'hook-hash',
'C04E2043B656B578CB30E9FF465304AF402B7AFE38B6CE2D8CEFECDD669E3424',
)
- expectSimpleRowText(hook2, 'hook-on', '98')
+ expectSimpleRowText(within(hook2), 'hook-on', '98')
expectSimpleRowText(
- hook2,
+ within(hook2),
'hook-namespace',
'0000000000000000000000000000000000000000000000000000000000000000',
)
- expectSimpleRowText(hook2, 'hook-flags', 'hsfOverride')
- expectSimpleRowText(hook2, 'hook-api-version', '0')
+ expectSimpleRowText(within(hook2), 'hook-flags', 'hsfOverride')
+ expectSimpleRowText(within(hook2), 'hook-api-version', '0')
})
it('renders a different SetHook tx', () => {
- const wrapper = createWrapper(mockSetHook2)
+ renderComponent(mockSetHook2)
- expect(wrapper.find('.group')).toHaveLength(1)
+ expect(screen.getAllByTestId('group')).toHaveLength(1)
- const hook = wrapper.find('.group').at(0)
+ const hook = screen.getAllByTestId('group')[0]
expectSimpleRowText(
- hook,
+ within(hook),
'hook-hash',
'548BBB700F5841C2D41E227456E8A80E6A6335D1149BA3B5FF745A00CC0EBECE',
)
+ const grants = within(hook).getAllByTestId('grant')
+ expect(grants).toHaveLength(2)
- expect(hook.find('.grant')).toHaveLength(2)
+ const grant1 = grants[0]
+ const grant2 = grants[1]
- const grant1 = hook.find('.grant').at(0)
- const grant2 = hook.find('.grant').at(1)
-
- expect(grant1.find('.hash')).toHaveText(
+ expect(within(grant1).getByTestId('hash')).toHaveTextContent(
'096A70632BBB67488F4804AE55604A01F52226BD556E3589270D0D30C9A6AF81',
)
- expect(grant1.find('.account').at(0)).toHaveText(
+ expect(within(grant1).getAllByTestId('account')[0]).toHaveTextContent(
'rQUhXd7sopuga3taru3jfvc1BgVbscrb1X',
)
- expect(grant1.find(`.account a`)).toExist()
+ expect(
+ within(grant1).getByText('rQUhXd7sopuga3taru3jfvc1BgVbscrb1X'),
+ ).toHaveAttribute('href')
- expect(grant2.find('.hash')).toHaveText(
+ expect(within(grant2).getByTestId('hash')).toHaveTextContent(
'3F47684053E1A653E54EAC1C5F50BCBAF7F69078CEFB5846BB046CE44B8ECDC2',
)
- expect(grant2.find('.account').at(0)).toHaveText(
+ expect(within(grant2).getByTestId('account')).toHaveTextContent(
'raPSFU999HcwpyRojdNh2i96T22gY9fgxL',
)
- expect(grant2.find(`.account a`)).toExist()
+ expect(
+ within(grant2).getByText('raPSFU999HcwpyRojdNh2i96T22gY9fgxL'),
+ ).toHaveAttribute('href')
})
it('renders a failed SetHook tx', () => {
- const wrapper = createWrapper(mockSetHookFailure)
+ renderComponent(mockSetHookFailure)
- expect(wrapper.find('.group')).toHaveLength(1)
+ expect(screen.getAllByTestId('group')).toHaveLength(1)
- const hook = wrapper.find('.group').at(0)
+ const hook = screen.getAllByTestId('group')[0]
- expectSimpleRowText(hook, 'hook-hash', 'undefined')
+ expectSimpleRowText(within(hook), 'hook-hash', 'undefined')
- expectSimpleRowText(hook, 'hook-on', 'Payment')
+ expectSimpleRowText(within(hook), 'hook-on', 'Payment')
expectSimpleRowText(
- hook,
+ within(hook),
'hook-namespace',
'CAE662172FD450BB0CD710A769079C05BFC5D8E35EFA6576EDC7D0377AFDD4A2',
)
- expectSimpleRowText(hook, 'hook-flags', 'hsfOverride')
- expectSimpleRowText(hook, 'hook-api-version', '0')
+ expectSimpleRowText(within(hook), 'hook-flags', 'hsfOverride')
+ expectSimpleRowText(within(hook), 'hook-api-version', '0')
})
})
diff --git a/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyDescription.test.tsx b/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyDescription.test.tsx
index f8dd96327..eb6ba08e5 100644
--- a/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyDescription.test.tsx
@@ -1,24 +1,24 @@
+import { cleanup } from '@testing-library/react'
import SetRegularKey from './mock_data/SetRegularKey.json'
import SetRegularKeyUnset from './mock_data/SetRegularKeyUnsetKey.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description)
+const renderComponent = createDescriptionRenderFactory(Description)
describe('SetRegularKey: Description', () => {
+ afterEach(cleanup)
it('renders description for transaction', () => {
- const wrapper = createWrapper(SetRegularKey)
+ const { container } = renderComponent(SetRegularKey)
- expect(wrapper.html()).toBe(
+ expect(container.innerHTML).toBe(
`
set_regular_key_description rULyyLRoZ47P33Vapew67VoiRqPrZ2ejbp
`,
)
- wrapper.unmount()
})
it('renders description for transaction that unsets key', () => {
- const wrapper = createWrapper(SetRegularKeyUnset)
+ const { container } = renderComponent(SetRegularKeyUnset)
- expect(wrapper.html()).toBe(`
unset_regular_key_description
`)
- wrapper.unmount()
+ expect(container.innerHTML).toBe(`
unset_regular_key_description
`)
})
})
diff --git a/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeySimple.test.tsx b/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeySimple.test.tsx
index dbbf01785..4bd1a07b2 100644
--- a/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeySimple.test.tsx
+++ b/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeySimple.test.tsx
@@ -1,29 +1,28 @@
+import { cleanup, screen } from '@testing-library/react'
import SetRegularKey from './mock_data/SetRegularKey.json'
import SetRegularKeyUnset from './mock_data/SetRegularKeyUnsetKey.json'
import { Simple } from '../Simple'
-import { SimpleRow } from '../../SimpleRow'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
+import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('SetRegularKey: Simple', () => {
+ afterEach(cleanup)
it('renders Simple for transaction', () => {
- const wrapper = createWrapper(SetRegularKey)
- const keyRow = wrapper.find(SimpleRow)
-
- expect(keyRow.prop('label')).toBe(`regular_key`)
- expect(keyRow.find('.value').text()).toBe(
- `rULyyLRoZ47P33Vapew67VoiRqPrZ2ejbp`,
+ renderComponent(SetRegularKey)
+ expectSimpleRowLabel(screen, 'regular_key', 'regular_key')
+ expectSimpleRowText(
+ screen,
+ 'regular_key',
+ 'rULyyLRoZ47P33Vapew67VoiRqPrZ2ejbp',
)
- wrapper.unmount()
})
it('renders Simple for transaction that unsets key', () => {
- const wrapper = createWrapper(SetRegularKeyUnset)
- const keyRow = wrapper.find(SimpleRow)
+ renderComponent(SetRegularKeyUnset)
- expect(keyRow.prop('label')).toBe('')
- expect(keyRow.find('.unset').hostNodes().text()).toBe(`unset_regular_key`)
- wrapper.unmount()
+ expectSimpleRowLabel(screen, 'unset', 'unset')
+ expectSimpleRowText(screen, 'unset', 'unset_regular_key')
})
})
diff --git a/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyTableDetail.test.tsx b/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyTableDetail.test.tsx
index 713e350e6..bd7a3bdf6 100644
--- a/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/SetRegularKey/test/SetRegularKeyTableDetail.test.tsx
@@ -1,27 +1,22 @@
+import { cleanup } from '@testing-library/react'
import SetRegularKey from './mock_data/SetRegularKey.json'
import SetRegularKeyUnset from './mock_data/SetRegularKeyUnsetKey.json'
import { TableDetail } from '../TableDetail'
-import { createTableDetailWrapperFactory } from '../../test'
+import { createTableDetailRenderFactory } from '../../test'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
-describe('SetRegularKeyTable: Detail', () => {
+describe('SetRegularKeyTable: TableDetail', () => {
+ afterEach(cleanup)
it('renders Simple for transaction', () => {
- const wrapper = createWrapper(SetRegularKey)
+ const { container } = renderComponent(SetRegularKey)
- expect(wrapper.find('.setregularkey')).toExist()
- expect(wrapper.find('.label').text()).toBe(`regular_key`)
- expect(wrapper.find('.key').text()).toBe(
- `rULyyLRoZ47P33Vapew67VoiRqPrZ2ejbp`,
- )
- wrapper.unmount()
+ expect(container).toHaveTextContent(`rULyyLRoZ47P33Vapew67VoiRqPrZ2ejbp`)
})
it('renders Simple for transaction that unsets key', () => {
- const wrapper = createWrapper(SetRegularKeyUnset)
+ const { container } = renderComponent(SetRegularKeyUnset)
- expect(wrapper.find('.unset')).toExist()
- expect(wrapper.text()).toBe(`unset_regular_key`)
- wrapper.unmount()
+ expect(container).toHaveTextContent(`unset_regular_key`)
})
})
diff --git a/src/containers/shared/components/Transaction/SignerListSet/Description.tsx b/src/containers/shared/components/Transaction/SignerListSet/Description.tsx
index 539cb4901..122d444de 100644
--- a/src/containers/shared/components/Transaction/SignerListSet/Description.tsx
+++ b/src/containers/shared/components/Transaction/SignerListSet/Description.tsx
@@ -17,7 +17,7 @@ export const Description = ({
{tx.SignerEntries?.map((d) => (
- -
+
-
{` - ${t('weight')}: `}
{d.SignerEntry.SignerWeight}
diff --git a/src/containers/shared/components/Transaction/SignerListSet/Simple.tsx b/src/containers/shared/components/Transaction/SignerListSet/Simple.tsx
index eeab19230..f43b21b7f 100644
--- a/src/containers/shared/components/Transaction/SignerListSet/Simple.tsx
+++ b/src/containers/shared/components/Transaction/SignerListSet/Simple.tsx
@@ -15,7 +15,7 @@ export const Simple = ({
{signers.map((d) => (
- -
+
-
{` ${t('weight')}: `}
{d.weight}
diff --git a/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetDescription.test.tsx b/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetDescription.test.tsx
index ad0a56932..9eb18de01 100644
--- a/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetDescription.test.tsx
@@ -1,33 +1,33 @@
+import { cleanup, screen } from '@testing-library/react'
import mockSignerListSetClear from './mock_data/SignerListSetClear.json'
import mockSignerListSet from './mock_data/SignerListSet.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description)
+const renderComponent = createDescriptionRenderFactory(Description)
describe('SignerListSet: Description', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockSignerListSet)
+ const { container } = renderComponent(mockSignerListSet)
- expect(wrapper.find('div').at(0).text()).toEqual(
- 'set_signer_list_description:',
- )
+ expect(container).toHaveTextContent('set_signer_list_description:')
+
+ const signers = screen.getAllByTestId('signer')
- const signers = wrapper.find('.signers li')
- expect(signers.at(0)).toHaveText(
+ expect(signers[0]).toHaveTextContent(
'rK8MWkYVgHR6VmPH6WpWcvVce9evvMpKSv - weight: 2',
)
- expect(signers.at(1)).toHaveText(
+ expect(signers[1]).toHaveTextContent(
'rLoRH7XuBgz2kTP1ACkoyVYk9hsLggVvbP - weight: 1',
)
- expect(signers.at(2)).toHaveText(
+ expect(signers[2]).toHaveTextContent(
'rL6SsrxyVp1JLNEZsX1hFWHcP2iJcZJ2dy - weight: 1',
)
})
it('renders when signer list is cleared', () => {
- const wrapper = createWrapper(mockSignerListSetClear)
- expect(wrapper).toHaveText('unset_signer_list_description')
- wrapper.unmount()
+ const { container } = renderComponent(mockSignerListSetClear)
+ expect(container).toHaveTextContent('unset_signer_list_description')
})
})
diff --git a/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetSimple.test.tsx b/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetSimple.test.tsx
index 4330dc059..0057a5045 100644
--- a/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetSimple.test.tsx
@@ -1,35 +1,32 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import mockSignerListSetClear from './mock_data/SignerListSetClear.json'
import mockSignerListSet from './mock_data/SignerListSet.json'
-import { SimpleRow } from '../../SimpleRow'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('SignerListSet: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockSignerListSet)
+ renderComponent(mockSignerListSet)
- expect(wrapper.find('[data-testid="quorum"] .value').text()).toEqual(
- '3 out_of 4',
- )
+ expect(screen.getByTestId('quorum')).toHaveTextContent('3 out_of 4')
- const signers = wrapper.find('[data-testid="signers"] .value li')
- expect(signers.at(0)).toHaveText(
+ const signers = screen.getAllByTestId('signer')
+ expect(signers[0]).toHaveTextContent(
'rK8MWkYVgHR6VmPH6WpWcvVce9evvMpKSv weight: 2',
)
- expect(signers.at(1)).toHaveText(
+ expect(signers[1]).toHaveTextContent(
'rLoRH7XuBgz2kTP1ACkoyVYk9hsLggVvbP weight: 1',
)
- expect(signers.at(2)).toHaveText(
+ expect(signers[2]).toHaveTextContent(
'rL6SsrxyVp1JLNEZsX1hFWHcP2iJcZJ2dy weight: 1',
)
- wrapper.unmount()
})
it('renders when signer list is cleared', () => {
- const wrapper = createWrapper(mockSignerListSetClear)
- expect(wrapper.find(SimpleRow)).toHaveText('unset_signer_list')
- wrapper.unmount()
+ const { container } = renderComponent(mockSignerListSetClear)
+ expect(container).toHaveTextContent('unset_signer_list')
})
})
diff --git a/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetTableDetail.test.tsx b/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetTableDetail.test.tsx
index 9de69b6d1..29d76fafa 100644
--- a/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/SignerListSet/test/SignerListSetTableDetail.test.tsx
@@ -1,21 +1,21 @@
+import { cleanup } from '@testing-library/react'
import { TableDetail } from '../TableDetail'
import mockSignerListSetClear from './mock_data/SignerListSetClear.json'
import mockSignerListSet from './mock_data/SignerListSet.json'
-import { createTableDetailWrapperFactory } from '../../test'
+import { createTableDetailRenderFactory } from '../../test'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('SignerListSet: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockSignerListSet)
- expect(wrapper).toHaveText('signers: 3 - quorum: 3/4')
- wrapper.unmount()
+ const { container } = renderComponent(mockSignerListSet)
+ expect(container).toHaveTextContent('signers: 3 - quorum: 3/4')
})
it('renders when signer list is cleared', () => {
- const wrapper = createWrapper(mockSignerListSetClear)
- expect(wrapper).toHaveText('unset_signer_list')
- wrapper.unmount()
+ const { container } = renderComponent(mockSignerListSetClear)
+ expect(container).toHaveTextContent('unset_signer_list')
})
})
diff --git a/src/containers/shared/components/Transaction/SimpleRow.tsx b/src/containers/shared/components/Transaction/SimpleRow.tsx
index 8d443162e..171d81163 100644
--- a/src/containers/shared/components/Transaction/SimpleRow.tsx
+++ b/src/containers/shared/components/Transaction/SimpleRow.tsx
@@ -4,12 +4,13 @@ import classnames from 'classnames'
export type SimpleRowProps = PropsWithChildren<{
className?: string
label: string
+ 'data-testid'?: string
}>
export const SimpleRow = (props: SimpleRowProps) => {
- const { label, children, className } = props
+ const { label, children, className, 'data-testid': testId } = props
return (
-
+
diff --git a/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateSimple.test.tsx b/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateSimple.test.tsx
index 7b2e02349..d5b6d9c45 100644
--- a/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateSimple.test.tsx
@@ -1,13 +1,14 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import TicketCreate from './mock_data/TicketCreate.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('TicketCreate: Simple', () => {
+ afterEach(cleanup)
it('renders ticket count', () => {
- const wrapper = createWrapper(TicketCreate)
- expectSimpleRowText(wrapper, 'ticket-count', '1')
- wrapper.unmount()
+ renderComponent(TicketCreate)
+ expectSimpleRowText(screen, 'ticket-count', '1')
})
})
diff --git a/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateTableDetail.test.tsx b/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateTableDetail.test.tsx
index 93dfe9461..2ac349333 100644
--- a/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/TicketCreate/test/TicketCreateTableDetail.test.tsx
@@ -1,13 +1,14 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import TicketCreate from './mock_data/TicketCreate.json'
-const createWrapper = createTableDetailWrapperFactory(TableDetail)
+const renderComponent = createTableDetailRenderFactory(TableDetail)
describe('TicketCreate: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(TicketCreate)
- expect(wrapper).toHaveText('ticket_count: 1')
- wrapper.unmount()
+ const { container } = renderComponent(TicketCreate)
+ expect(container).toHaveTextContent('ticket_count: 1')
})
})
diff --git a/src/containers/shared/components/Transaction/TrustSet/Simple.tsx b/src/containers/shared/components/Transaction/TrustSet/Simple.tsx
index af9b743d4..39b1cbb90 100644
--- a/src/containers/shared/components/Transaction/TrustSet/Simple.tsx
+++ b/src/containers/shared/components/Transaction/TrustSet/Simple.tsx
@@ -10,7 +10,7 @@ export const Simple = ({ data }: TransactionSimpleProps
) => {
const { LimitAmount } = data.instructions
return (
-
+
)
diff --git a/src/containers/shared/components/Transaction/TrustSet/test/TrustSetDescription.test.tsx b/src/containers/shared/components/Transaction/TrustSet/test/TrustSetDescription.test.tsx
index c1826319f..933be4858 100644
--- a/src/containers/shared/components/Transaction/TrustSet/test/TrustSetDescription.test.tsx
+++ b/src/containers/shared/components/Transaction/TrustSet/test/TrustSetDescription.test.tsx
@@ -1,18 +1,19 @@
+import { cleanup } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import mockTrustSet from './mock_data/TrustSet.json'
import { Description } from '../Description'
-import { createDescriptionWrapperFactory } from '../../test'
+import { createDescriptionRenderFactory } from '../../test'
-const createWrapper = createDescriptionWrapperFactory(Description, i18n)
+const renderComponent = createDescriptionRenderFactory(Description, i18n)
describe('TrustSet: Description', () => {
+ afterEach(cleanup)
it('renders description for authorize', () => {
- const wrapper = createWrapper(mockTrustSet)
- expect(wrapper.html()).toBe(
+ const { container } = renderComponent(mockTrustSet)
+ expect(container.innerHTML).toBe(
``,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/TrustSet/test/TrustSetSimple.test.tsx b/src/containers/shared/components/Transaction/TrustSet/test/TrustSetSimple.test.tsx
index e28a45a95..92be732ee 100644
--- a/src/containers/shared/components/Transaction/TrustSet/test/TrustSetSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/TrustSet/test/TrustSetSimple.test.tsx
@@ -1,21 +1,22 @@
+import { cleanup, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockTrustSet from './mock_data/TrustSet.json'
import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('TrustSet: Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockTrustSet)
- expectSimpleRowLabel(wrapper, 'amount', 'Set Trust Limit')
+ renderComponent(mockTrustSet)
+ expectSimpleRowLabel(screen, 'limit-amount', 'Set Trust Limit')
expectSimpleRowText(
- wrapper,
- 'amount',
+ screen,
+ 'limit-amount',
`CN¥1,000,000,000.00 CNY.razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA`,
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/TrustSet/test/TrustSetTableDetail.test.tsx b/src/containers/shared/components/Transaction/TrustSet/test/TrustSetTableDetail.test.tsx
index d1f200684..2939cbc66 100644
--- a/src/containers/shared/components/Transaction/TrustSet/test/TrustSetTableDetail.test.tsx
+++ b/src/containers/shared/components/Transaction/TrustSet/test/TrustSetTableDetail.test.tsx
@@ -1,17 +1,18 @@
-import { createTableDetailWrapperFactory } from '../../test'
+import { cleanup } from '@testing-library/react'
+import { createTableDetailRenderFactory } from '../../test'
import { TableDetail } from '../TableDetail'
import mockTrustSet from './mock_data/TrustSet.json'
import i18n from '../../../../../../i18n/testConfigEnglish'
-const createWrapper = createTableDetailWrapperFactory(TableDetail, i18n)
+const renderComponent = createTableDetailRenderFactory(TableDetail, i18n)
describe('TrustSet: TableDetail', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockTrustSet)
- expect(wrapper.find('.label')).toHaveText('Set Trust Limit')
- expect(wrapper.find('Amount')).toHaveText(
+ const { container } = renderComponent(mockTrustSet)
+ expect(container).toHaveTextContent('Set Trust Limit')
+ expect(container).toHaveTextContent(
'CN¥1,000,000,000.00 CNY.razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/UNLModify/test/UNLModifySimple.test.tsx b/src/containers/shared/components/Transaction/UNLModify/test/UNLModifySimple.test.tsx
index 6a17eaffb..c0d466e58 100644
--- a/src/containers/shared/components/Transaction/UNLModify/test/UNLModifySimple.test.tsx
+++ b/src/containers/shared/components/Transaction/UNLModify/test/UNLModifySimple.test.tsx
@@ -1,46 +1,45 @@
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import i18n from '../../../../../../i18n/testConfigEnglish'
import { expectSimpleRowLabel, expectSimpleRowText } from '../../test'
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockUNLModifyEnable from './mock_data/UNLModifyEnable.json'
import mockUNLModifyDisable from './mock_data/UNLModifyDisable.json'
-import { SimpleTab } from '../../../../../Transactions/SimpleTab'
-import { QuickHarness } from '../../../../../test/utils'
import summarizeTransaction from '../../../../../../rippled/lib/txSummary'
+import { QuickHarness } from '../../../../../test/utils'
+import { SimpleTab } from '../../../../../Transactions/SimpleTab'
-const createWrapper = createSimpleWrapperFactory(Simple, i18n)
+const renderComponent = createSimpleRenderFactory(Simple, i18n)
describe('UNLModify: Simple', () => {
+ afterEach(cleanup)
it('renders tx that enables a validator', () => {
- const wrapper = createWrapper(mockUNLModifyEnable)
- expectSimpleRowLabel(wrapper, 'validator', 'Validator')
+ renderComponent(mockUNLModifyEnable)
+ expectSimpleRowLabel(screen, 'validator', 'Validator')
expectSimpleRowText(
- wrapper,
+ screen,
'validator',
'nHUXeusfwk61c4xJPneb9Lgy7Ga6DVaVLEyB29ftUdt9k2KxD6Hw',
)
- expectSimpleRowLabel(wrapper, 'action', 'action')
- expectSimpleRowText(wrapper, 'action', 'ENABLE')
- wrapper.unmount()
+ expectSimpleRowLabel(screen, 'action', 'action')
+ expectSimpleRowText(screen, 'action', 'ENABLE')
})
it('renders tx that disables a validator', () => {
- const wrapper = createWrapper(mockUNLModifyDisable)
- expectSimpleRowLabel(wrapper, 'validator', 'Validator')
+ renderComponent(mockUNLModifyDisable)
+ expectSimpleRowLabel(screen, 'validator', 'Validator')
expectSimpleRowText(
- wrapper,
+ screen,
'validator',
'nHUXeusfwk61c4xJPneb9Lgy7Ga6DVaVLEyB29ftUdt9k2KxD6Hw',
)
- expectSimpleRowLabel(wrapper, 'action', 'action')
- expectSimpleRowText(wrapper, 'action', 'DISABLE')
- wrapper.unmount()
+ expectSimpleRowLabel(screen, 'action', 'action')
+ expectSimpleRowText(screen, 'action', 'DISABLE')
})
it('renders tx with correct account and sequence', () => {
- const wrapper = mount(
+ render(
{
/>
,
)
- expect(wrapper.find('[data-testid="account"]')).not.toExist()
- expectSimpleRowLabel(wrapper, 'sequence', 'Sequence Number')
- expectSimpleRowText(wrapper, 'sequence', '0')
-
- wrapper.unmount()
+ expect(screen.queryByTestId('account')).toBeNull()
+ expectSimpleRowLabel(screen, 'sequence', 'Sequence Number')
+ expectSimpleRowText(screen, 'sequence', '0')
})
})
diff --git a/src/containers/shared/components/Transaction/XChainAccountCreateCommit/test/XChainAccountCreateCommitSimple.test.tsx b/src/containers/shared/components/Transaction/XChainAccountCreateCommit/test/XChainAccountCreateCommitSimple.test.tsx
index f21484912..e4acd0b0b 100644
--- a/src/containers/shared/components/Transaction/XChainAccountCreateCommit/test/XChainAccountCreateCommitSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainAccountCreateCommit/test/XChainAccountCreateCommitSimple.test.tsx
@@ -1,67 +1,79 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockXChainAccountCreateCommit from './mock_data/XChainAccountCreateCommit.json'
import mockXChainAccountCreateCommitInsufficientFunds from './mock_data/XChainAccountCreateCommitInsufficientFunds.json'
import { expectSimpleRowText } from '../../test/expectations'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainAccountCreateCommitSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainAccountCreateCommit)
+ renderComponent(mockXChainAccountCreateCommit)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'send', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
)
- expect(wrapper.find(`[data-testid="destination"] a`)).not.toExist()
+ expect(
+ screen.getByText('raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym'),
+ ).not.toHaveAttribute('href')
})
it('renders failed transaction', () => {
- const wrapper = createWrapper(
- mockXChainAccountCreateCommitInsufficientFunds,
- )
+ renderComponent(mockXChainAccountCreateCommitInsufficientFunds)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE9001,000.00 XRP')
+ expectSimpleRowText(screen, 'send', '\uE9001,000.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
)
- expect(wrapper.find(`[data-testid="destination"] a`)).not.toExist()
+ expect(
+ screen.getByText('raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym'),
+ ).not.toHaveAttribute('href')
})
})
diff --git a/src/containers/shared/components/Transaction/XChainAddAccountCreateAttestation/test/XChainAddAccountCreateAttestationSimple.test.tsx b/src/containers/shared/components/Transaction/XChainAddAccountCreateAttestation/test/XChainAddAccountCreateAttestationSimple.test.tsx
index eb6bbca43..996f7b018 100644
--- a/src/containers/shared/components/Transaction/XChainAddAccountCreateAttestation/test/XChainAddAccountCreateAttestationSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainAddAccountCreateAttestation/test/XChainAddAccountCreateAttestationSimple.test.tsx
@@ -1,75 +1,77 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockXChainAddAccountCreateAttestation from './mock_data/XChainAddAccountCreateAttestation.json'
import mockXChainAddAccountCreateAttestationFailed from './mock_data/XChainAddAccountCreateAttestationFailed.json'
import { expectSimpleRowText } from '../../test/expectations'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
-describe('XChainAddAccountCreateAttestationSimple', () => {
+describe('XChainAddAccountCreateAttestation - Simple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainAddAccountCreateAttestation)
+ renderComponent(mockXChainAddAccountCreateAttestation)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rDPwN6dz3shffxodeUC9Qf5y1mEHYySKLJ',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(screen.getByTestId('locking-chain-door')).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(screen.getByTestId('issuing-chain-door')).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'send', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'other_chain_source',
'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rLbKhMNskUBYRShdbbQcFm9YhumEeUJfPK',
)
- expect(wrapper.find(`[data-testid="destination"] a`)).toExist()
+ expect(screen.getByTestId('destination')).not.toHaveAttribute('href')
})
it('renders failed transaction', () => {
- const wrapper = createWrapper(mockXChainAddAccountCreateAttestationFailed)
+ renderComponent(mockXChainAddAccountCreateAttestationFailed)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rNFrsx478pH42Vy5w4KN9Hcyh8SDrVmCfd',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(screen.getByTestId('locking-chain-door')).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(screen.getByTestId('issuing-chain-door')).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'send', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'other_chain_source',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rPy1F9bQ7dNn2T3QAFRM6dFz6ygHa3MDDi',
)
- expect(wrapper.find(`[data-testid="destination"] a`)).toExist()
+ expect(screen.getByTestId('destination')).not.toHaveAttribute('href')
})
})
diff --git a/src/containers/shared/components/Transaction/XChainAddClaimAttestation/test/XChainAddClaimAttestationSimple.test.tsx b/src/containers/shared/components/Transaction/XChainAddClaimAttestation/test/XChainAddClaimAttestationSimple.test.tsx
index d86c3287f..5752388c4 100644
--- a/src/containers/shared/components/Transaction/XChainAddClaimAttestation/test/XChainAddClaimAttestationSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainAddClaimAttestation/test/XChainAddClaimAttestationSimple.test.tsx
@@ -1,77 +1,91 @@
-import { createSimpleWrapperFactory } from '../../test/createWrapperFactory'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory } from '../../test/createRenderFactory'
import { Simple } from '../Simple'
import mockXChainAddClaimAttestation from './mock_data/XChainAddClaimAttestation.json'
import mockXChainAddClaimAttestationFailed from './mock_data/XChainAddClaimAttestationFailed.json'
import { expectSimpleRowText } from '../../test/expectations'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainAddClaimAttestationSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainAddClaimAttestation)
+ renderComponent(mockXChainAddClaimAttestation)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'r3ZsJYkBao2qiwUCvmjfgEUquKueLAwPxQ',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('r3ZsJYkBao2qiwUCvmjfgEUquKueLAwPxQ'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'send', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'other_chain_source',
'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi',
)
- expect(wrapper.find(`[data-testid="destination"] a`)).toExist()
- expectSimpleRowText(wrapper, 'xchain-claim-id', '1')
+ expect(
+ screen.getByText('rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'xchain-claim-id', '1')
})
it('renders failed transaction', () => {
- const wrapper = createWrapper(mockXChainAddClaimAttestationFailed)
+ renderComponent(mockXChainAddClaimAttestationFailed)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rNFrsx478pH42Vy5w4KN9Hcyh8SDrVmCfd',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rNFrsx478pH42Vy5w4KN9Hcyh8SDrVmCfd'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'send', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'other_chain_source',
'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
)
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi',
)
- expect(wrapper.find(`[data-testid="destination"] a`)).toExist()
- expectSimpleRowText(wrapper, 'xchain-claim-id', '3')
+ expect(
+ screen.getByText('rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'xchain-claim-id', '3')
})
})
diff --git a/src/containers/shared/components/Transaction/XChainClaim/Simple.tsx b/src/containers/shared/components/Transaction/XChainClaim/Simple.tsx
index 05900b4f8..ee41cdd51 100644
--- a/src/containers/shared/components/Transaction/XChainClaim/Simple.tsx
+++ b/src/containers/shared/components/Transaction/XChainClaim/Simple.tsx
@@ -36,7 +36,7 @@ export const Simple: TransactionSimpleComponent = (
-
+
>
diff --git a/src/containers/shared/components/Transaction/XChainClaim/test/XChainClaimSimple.test.tsx b/src/containers/shared/components/Transaction/XChainClaim/test/XChainClaimSimple.test.tsx
index 9147d645b..1273b7a92 100644
--- a/src/containers/shared/components/Transaction/XChainClaim/test/XChainClaimSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainClaim/test/XChainClaimSimple.test.tsx
@@ -1,64 +1,74 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import mockXChainClaim from './mock_data/XChainClaim.json'
import mockXChainClaimNoQuorum from './mock_data/XChainClaimNoQuorum.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainClaimSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainClaim)
+ renderComponent(mockXChainClaim)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'amount', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'amount', '\uE90010.00 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi',
)
- expectSimpleRowText(wrapper, 'claim-id', '5')
+ expectSimpleRowText(screen, 'claim-id', '5')
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockXChainClaimNoQuorum)
+ renderComponent(mockXChainClaimNoQuorum)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'amount', '\uE9000.01 XRP')
+ expectSimpleRowText(screen, 'claim-amount', '\uE9000.01 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rpwoKyUQn5uGDKeF6LhxK8HWS25ZMhFpaB',
)
- expectSimpleRowText(wrapper, 'claim-id', '492')
+ expectSimpleRowText(screen, 'claim-id', '492')
})
})
diff --git a/src/containers/shared/components/Transaction/XChainCommit/test/XChainCommitSimple.test.tsx b/src/containers/shared/components/Transaction/XChainCommit/test/XChainCommitSimple.test.tsx
index c57575d6d..be4187702 100644
--- a/src/containers/shared/components/Transaction/XChainCommit/test/XChainCommitSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainCommit/test/XChainCommitSimple.test.tsx
@@ -1,59 +1,69 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import mockXChainCommit from './mock_data/XChainCommit.json'
import mockXChainCommitInsufficientFunds from './mock_data/XChainCommitInsufficientFunds.json'
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainCommitSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainCommit)
+ renderComponent(mockXChainCommit)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010.00 XRP')
- expectSimpleRowText(wrapper, 'claim-id', '4')
- expect(wrapper.find(`[data-testid="destination"]`)).not.toExist()
+ expectSimpleRowText(screen, 'send', '\uE90010.00 XRP')
+ expectSimpleRowText(screen, 'claim-id', '4')
+ expect(screen.queryByTestId('destination')).toBeNull()
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockXChainCommitInsufficientFunds)
+ renderComponent(mockXChainCommitInsufficientFunds)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'send', '\uE90010,000.00 XRP')
- expectSimpleRowText(wrapper, 'claim-id', '3')
+ expectSimpleRowText(screen, 'send', '\uE90010,000.00 XRP')
+ expectSimpleRowText(screen, 'claim-id', '3')
expectSimpleRowText(
- wrapper,
+ screen,
'destination',
'rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi',
)
diff --git a/src/containers/shared/components/Transaction/XChainCreateBridge/test/XChainCreateBridgeSimple.test.tsx b/src/containers/shared/components/Transaction/XChainCreateBridge/test/XChainCreateBridgeSimple.test.tsx
index d7a837909..99d273603 100644
--- a/src/containers/shared/components/Transaction/XChainCreateBridge/test/XChainCreateBridgeSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainCreateBridge/test/XChainCreateBridgeSimple.test.tsx
@@ -1,88 +1,100 @@
+import { cleanup, screen } from '@testing-library/react'
import { Simple } from '../Simple'
import mockXChainCreateBridge from './mock_data/XChainCreateBridge.json'
import mockXChainCreateBridgeFailed from './mock_data/XChainCreateBridgeFailed.json'
import mockXChainCreateBridgeIOU from './mock_data/XChainCreateBridgeIOU.json'
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainCreateBridgeSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainCreateBridge)
+ renderComponent(mockXChainCreateBridge)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
-
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.0001 XRP')
expect(
- wrapper.find(`[data-testid="min-create-account-amount"]`),
- ).not.toExist()
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
+
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.0001 XRP')
+ expect(screen.queryByTestId('min-create-account-amount')).toBeNull()
})
it('renders IOU bridge', () => {
- const wrapper = createWrapper(mockXChainCreateBridgeIOU)
+ renderComponent(mockXChainCreateBridgeIOU)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'ratAutb3katzezbXX3LsX4sk4vmvhNucac',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
+ expect(
+ screen.getByText('ratAutb3katzezbXX3LsX4sk4vmvhNucac'),
+ ).not.toHaveAttribute('href')
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-issue',
'USD.rNhm2aTLEnSdcWQ7d6PZ5F7TX5skM7wkAS',
)
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rBkRN2VHVWJVKqfnh1TovLkXo7vLP7oBcq',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).toExist()
+ expect(
+ screen.getByText('rBkRN2VHVWJVKqfnh1TovLkXo7vLP7oBcq'),
+ ).toHaveAttribute('href')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-issue',
'USD.rBkRN2VHVWJVKqfnh1TovLkXo7vLP7oBcq',
)
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.0001 XRP')
- expectSimpleRowText(wrapper, 'min-account-create-amount', '\uE9005.00 XRP')
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.0001 XRP')
+ expectSimpleRowText(screen, 'min-account-create-amount', '\uE9005.00 XRP')
})
it('renders failed tx', () => {
- const wrapper = createWrapper(mockXChainCreateBridgeFailed)
+ renderComponent(mockXChainCreateBridgeFailed)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rNFrsx478pH42Vy5w4KN9Hcyh8SDrVmCfd',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rNFrsx478pH42Vy5w4KN9Hcyh8SDrVmCfd'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.0001 XRP')
- expectSimpleRowText(wrapper, 'min-account-create-amount', '\uE9005.00 XRP')
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.0001 XRP')
+ expectSimpleRowText(screen, 'min-account-create-amount', '\uE9005.00 XRP')
})
})
diff --git a/src/containers/shared/components/Transaction/XChainCreateClaimID/test/XChainCreateClaimIDSimple.test.tsx b/src/containers/shared/components/Transaction/XChainCreateClaimID/test/XChainCreateClaimIDSimple.test.tsx
index ff6d62f6f..847073afd 100644
--- a/src/containers/shared/components/Transaction/XChainCreateClaimID/test/XChainCreateClaimIDSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainCreateClaimID/test/XChainCreateClaimIDSimple.test.tsx
@@ -1,64 +1,74 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import mockXChainCreateClaimID from './mock_data/XChainCreateClaimID.json'
import mockXChainCreateClaimIDFailed from './mock_data/XChainCreateClaimIDFailed.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainCreateClaimIDSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainCreateClaimID)
+ renderComponent(mockXChainCreateClaimID)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rNe5NbD1hqCSZPz9KM5PHm5Bf8jjHfezPE',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rNe5NbD1hqCSZPz9KM5PHm5Bf8jjHfezPE'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.0001 XRP')
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.0001 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'other-chain-source',
'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
)
- expectSimpleRowText(wrapper, 'claim-id', '1')
+ expectSimpleRowText(screen, 'claim-id', '1')
})
it('renders failed transaction', () => {
- const wrapper = createWrapper(mockXChainCreateClaimIDFailed)
+ renderComponent(mockXChainCreateClaimIDFailed)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ screen
+ .getAllByText('r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W')
+ .forEach((element) => expect(element).not.toHaveAttribute('href'))
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.0001 XRP')
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.0001 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'other-chain-source',
'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
)
- expect(wrapper.find(`[data-testid="claim-id"]`)).not.toExist()
+ expect(screen.queryByTestId('claim-id')).toBeNull()
})
})
diff --git a/src/containers/shared/components/Transaction/XChainModifyBridge/test/XChainModifyBridgeSimple.test.tsx b/src/containers/shared/components/Transaction/XChainModifyBridge/test/XChainModifyBridgeSimple.test.tsx
index 215580a71..4510a6249 100644
--- a/src/containers/shared/components/Transaction/XChainModifyBridge/test/XChainModifyBridgeSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/XChainModifyBridge/test/XChainModifyBridgeSimple.test.tsx
@@ -1,79 +1,89 @@
-import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test'
+import { cleanup, screen } from '@testing-library/react'
+import { createSimpleRenderFactory, expectSimpleRowText } from '../../test'
import { Simple } from '../Simple'
import mockXChainModifyBridge from './mock_data/XChainModifyBridge.json'
import mockXChainModifyBridgeMinAccountCreateAmount from './mock_data/XChainModifyBridgeMinAccountCreateAmount.json'
import mockXChainModifyBridgeNoEntry from './mock_data/XChainModifyBridgeNoEntry.json'
-const createWrapper = createSimpleWrapperFactory(Simple)
+const renderComponent = createSimpleRenderFactory(Simple)
describe('XChainModifyBridgeSimple', () => {
+ afterEach(cleanup)
it('renders', () => {
- const wrapper = createWrapper(mockXChainModifyBridge)
+ renderComponent(mockXChainModifyBridge)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rGQLcxzT3Po9PsCk5Lj9uK7S1juThii9cR'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.01 XRP')
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.01 XRP')
})
it('renders MinAccountCreateAmount', () => {
- const wrapper = createWrapper(mockXChainModifyBridgeMinAccountCreateAmount)
+ renderComponent(mockXChainModifyBridgeMinAccountCreateAmount)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'rnBnyot2gCJywLxLzfHQX2dUJqZ6oghUFp',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rnBnyot2gCJywLxLzfHQX2dUJqZ6oghUFp'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(
- wrapper,
- 'min-account-create-amount',
- '\uE900100.00 XRP',
- )
+ expectSimpleRowText(screen, 'min-account-create-amount', '\uE900100.00 XRP')
})
it('renders failed transaction', () => {
- const wrapper = createWrapper(mockXChainModifyBridgeNoEntry)
+ renderComponent(mockXChainModifyBridgeNoEntry)
// check XChainBridge parts
expectSimpleRowText(
- wrapper,
+ screen,
'locking-chain-door',
'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
)
- expect(wrapper.find(`[data-testid="locking-chain-door"] a`)).not.toExist()
- expectSimpleRowText(wrapper, 'locking-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W'),
+ ).not.toHaveAttribute('href')
+ expectSimpleRowText(screen, 'locking-chain-issue', '\uE900 XRP')
expectSimpleRowText(
- wrapper,
+ screen,
'issuing-chain-door',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="issuing-chain-door"] a`)).toExist()
- expectSimpleRowText(wrapper, 'issuing-chain-issue', '\uE900 XRP')
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'issuing-chain-issue', '\uE900 XRP')
- expectSimpleRowText(wrapper, 'signature-reward', '\uE9000.0001 XRP')
+ expectSimpleRowText(screen, 'signature-reward', '\uE9000.0001 XRP')
})
})
diff --git a/src/containers/shared/components/Transaction/test/DefaultSimple.test.tsx b/src/containers/shared/components/Transaction/test/DefaultSimple.test.tsx
index f80c0b5dc..2dfb5e7e5 100644
--- a/src/containers/shared/components/Transaction/test/DefaultSimple.test.tsx
+++ b/src/containers/shared/components/Transaction/test/DefaultSimple.test.tsx
@@ -1,124 +1,113 @@
+import { cleanup, screen, within } from '@testing-library/react'
import NewEscrowCreate from './mock_data/NewEscrowCreate.json'
import SetHook from './mock_data/SetHook.json'
import SetHook2 from './mock_data/SetHook2.json'
import TokenSwapPropose from './mock_data/TokenSwapPropose.json'
import { DefaultSimple } from '../DefaultSimple'
-import { createWrapper as createGeneralWrapper } from './createWrapperFactory'
+import { renderComponent as renderGeneralComponent } from './createRenderFactory'
import { expectSimpleRowText } from './expectations'
import summarizeTransaction from '../../../../../rippled/lib/txSummary'
-function createWrapper(tx: { tx: any; meta: any }) {
+function renderComponent(tx: { tx: any; meta: any }) {
// eslint-disable-next-line no-param-reassign -- needed so parsers aren't triggered
tx.tx.TransactionType = 'DummyTx'
const data = summarizeTransaction(tx, true)
- return createGeneralWrapper()
+ return renderGeneralComponent()
}
describe('DefaultSimple', () => {
+ afterEach(cleanup)
it('renders Simple for basic transaction', () => {
- const wrapper = createWrapper(NewEscrowCreate)
+ renderComponent(NewEscrowCreate)
expectSimpleRowText(
- wrapper,
+ screen,
'Destination',
'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
)
- expect(wrapper.find(`[data-testid="Destination"] a`)).toExist()
- expectSimpleRowText(wrapper, 'Amount', '\uE9001.00 XRP')
- expectSimpleRowText(wrapper, 'FinishAfter', '736447590')
- wrapper.unmount()
+ expect(
+ screen.getByText('rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'),
+ ).toHaveAttribute('href')
+ expectSimpleRowText(screen, 'Amount', '\uE9001.00 XRP')
+ expectSimpleRowText(screen, 'FinishAfter', '736447590')
})
it('renders Simple for more complex transaction', () => {
- const wrapper = createWrapper(SetHook)
- expect(wrapper.find(`[data-testid="group"]`).length).toEqual(10)
- expect(wrapper.find(`[data-testid="CreateCode"]`).length).toEqual(10)
- expect(wrapper.find(`[data-testid="Flags"]`).length).toEqual(10)
- expect(wrapper.find(`[data-testid="HookApiVersion"]`).length).toEqual(2)
- expect(wrapper.find(`[data-testid="HookNamespace"]`).length).toEqual(2)
- expect(wrapper.find(`[data-testid="HookOn"]`).length).toEqual(2)
+ renderComponent(SetHook)
+ expect(screen.getAllByTestId('group').length).toEqual(10)
+ expect(screen.getAllByTestId('CreateCode').length).toEqual(10)
+ expect(screen.getAllByTestId('Flags').length).toEqual(10)
+ expect(screen.getAllByTestId('HookApiVersion').length).toEqual(2)
+ expect(screen.getAllByTestId('HookNamespace').length).toEqual(2)
+ expect(screen.getAllByTestId('HookOn').length).toEqual(2)
- expect(wrapper.find(`[data-testid="CreateCode"] .value`).at(0)).toHaveText(
+ expect(screen.getAllByTestId('CreateCode')[0]).toHaveTextContent(
'0061736D0100000001420960027F7F017F60037F7F7F017E60037F7F7E017E60027F7F017E60047F' +
'7F7F7F017E60017F017E6000017E60057F7F7F7F7F017E60097F7F7F7F7F7F7F7F7F017E02BC02' +
'1403656E76025F67000003656E760A6F74786E5F6669656C64000103656E760661636365707400' +
'0203656E7608726F6C6C6261636B000203656E760C686F6F6B5F6163636F756E...',
)
- expect(wrapper.find(`[data-testid="Flags"] .value`).at(0)).toHaveText('1')
- expect(
- wrapper.find(`[data-testid="HookApiVersion"] .value`).at(0),
- ).toHaveText('0')
- expect(
- wrapper.find(`[data-testid="HookNamespace"] .value`).at(0),
- ).toHaveText(
+ expect(screen.getAllByTestId('Flags')[0]).toHaveTextContent('1')
+ expect(screen.getAllByTestId('HookApiVersion')[0]).toHaveTextContent('0')
+ expect(screen.getAllByTestId('HookNamespace')[0]).toHaveTextContent(
'0000000000000000000000000000000000000000000000000000000000000000',
)
- expect(wrapper.find(`[data-testid="HookOn"] .value`).at(0)).toHaveText(
+ expect(screen.getAllByTestId('HookOn')[0]).toHaveTextContent(
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFFFFFFBFFFFF',
)
-
- wrapper.unmount()
})
it('renders Simple for more complex transaction', () => {
- const wrapper = createWrapper(SetHook2)
- expect(wrapper.find(`[data-testid="group"]`).length).toEqual(1)
- expect(wrapper.find(`[data-testid="CreateCode"]`).length).toEqual(1)
- expect(wrapper.find(`[data-testid="Flags"]`).length).toEqual(1)
- expect(wrapper.find(`[data-testid="HookApiVersion"]`).length).toEqual(1)
- expect(wrapper.find(`[data-testid="HookNamespace"]`).length).toEqual(1)
- expect(wrapper.find(`[data-testid="HookOn"]`).length).toEqual(1)
- expect(wrapper.find(`[data-testid="HookParameters"]`).length).toEqual(1)
+ renderComponent(SetHook2)
+ expect(screen.getAllByTestId('group').length).toEqual(1)
+ expect(screen.getAllByTestId('CreateCode').length).toEqual(1)
+ expect(screen.getAllByTestId('Flags').length).toEqual(1)
+ expect(screen.getAllByTestId('HookApiVersion').length).toEqual(1)
+ expect(screen.getAllByTestId('HookNamespace').length).toEqual(1)
+ expect(screen.getAllByTestId('HookOn').length).toEqual(1)
+ expect(screen.getAllByTestId('HookParameters').length).toEqual(1)
- expect(wrapper.find(`[data-testid="CreateCode"] .value`).at(0)).toHaveText(
+ expect(screen.getByTestId('CreateCode')).toHaveTextContent(
'0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E0223' +
'0303656E76057472616365000003656E7606616363657074000103656E76025F6700020302010305' +
'030100020621057F0141B088040B7F0041A6080B7F004180080B7F0041B088040B7F004180080B07' +
'080104686F6F6B00030AC6800001C2800002017F017E230041106B220124...',
)
- expect(wrapper.find(`[data-testid="Flags"] .value`).at(0)).toHaveText('1')
- expect(
- wrapper.find(`[data-testid="HookApiVersion"] .value`).at(0),
- ).toHaveText('0')
- expect(
- wrapper.find(`[data-testid="HookNamespace"] .value`).at(0),
- ).toHaveText(
+ expect(screen.getByTestId('Flags')).toHaveTextContent('1')
+ expect(screen.getByTestId('HookApiVersion')).toHaveTextContent('0')
+ expect(screen.getByTestId('HookNamespace')).toHaveTextContent(
'4FF9961269BF7630D32E15276569C94470174A5DA79FA567C0F62251AA9A36B9',
)
- expect(wrapper.find(`[data-testid="HookOn"] .value`).at(0)).toHaveText(
+ expect(screen.getByTestId('HookOn')).toHaveTextContent(
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFFFFFFBFFFFF',
)
+ const hookParams = screen.getByTestId('HookParameters')
expect(
- wrapper.find(
- `[data-testid="HookParameters"] .subgroup [data-testid="HookParameterName"]`,
- ),
- ).toHaveText('HookParameterName: 6E616D6531')
+ within(hookParams).getByTestId('HookParameterName'),
+ ).toHaveTextContent('HookParameterName: 6E616D6531')
expect(
- wrapper.find(
- `[data-testid="HookParameters"] .subgroup [data-testid="HookParameterValue"]`,
- ),
- ).toHaveText('HookParameterValue: 76616C756531')
-
- wrapper.unmount()
+ within(hookParams).getByTestId('HookParameterValue'),
+ ).toHaveTextContent('HookParameterValue: 76616C756531')
})
it('renders Simple for amount', () => {
- const wrapper = createWrapper(TokenSwapPropose)
+ renderComponent(TokenSwapPropose)
expectSimpleRowText(
- wrapper,
+ screen,
'AccountOther',
'rPTScb8m3wq6r3Ys93Ec5at7LYDmWrtndi',
)
- expect(wrapper.find(`[data-testid="AccountOther"] a`)).toExist()
+ expect(
+ screen.getByText('rPTScb8m3wq6r3Ys93Ec5at7LYDmWrtndi'),
+ ).toHaveAttribute('href')
expectSimpleRowText(
- wrapper,
+ screen,
'Amount',
'€12.00 EUR.rnz5f1MFcgbVxzYhU5hUKbKquEJHJady5K',
)
expectSimpleRowText(
- wrapper,
+ screen,
'AmountOther',
'$33.00 USD.rnz5f1MFcgbVxzYhU5hUKbKquEJHJady5K',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/Transaction/test/createWrapperFactory.tsx b/src/containers/shared/components/Transaction/test/createRenderFactory.tsx
similarity index 72%
rename from src/containers/shared/components/Transaction/test/createWrapperFactory.tsx
rename to src/containers/shared/components/Transaction/test/createRenderFactory.tsx
index 9c93c4a01..8bef5221c 100644
--- a/src/containers/shared/components/Transaction/test/createWrapperFactory.tsx
+++ b/src/containers/shared/components/Transaction/test/createRenderFactory.tsx
@@ -1,9 +1,9 @@
-import { mount, ReactWrapper } from 'enzyme'
import { ReactElement } from 'react'
import { I18nextProvider } from 'react-i18next'
import { BrowserRouter } from 'react-router-dom'
import { i18n } from 'i18next'
import { QueryClientProvider } from 'react-query'
+import { RenderResult, render } from '@testing-library/react'
import defaultI18nConfig from '../../../../../i18n/testConfig'
import summarizeTransaction from '../../../../../rippled/lib/txSummary'
import {
@@ -14,16 +14,16 @@ import {
import { testQueryClient } from '../../../../test/QueryClient'
/**
- * Methods that produce createWrapper function for tests
+ * Methods that produce renderComponent function for tests
* @param TestComponent - react component to test
* @param i18nConfig - i18next configuration to use instead of the default which outputs the key as the value
*/
-export function createWrapper(
+export function renderComponent(
TestComponent: ReactElement,
i18nConfig?: i18n,
-): ReactWrapper {
- return mount(
+): RenderResult {
+ return render(
{TestComponent}
@@ -32,33 +32,33 @@ export function createWrapper(
)
}
-export function createDescriptionWrapperFactory(
+export function createDescriptionRenderFactory(
Description: TransactionDescriptionComponent,
i18nConfig?: i18n,
-): (tx: any) => ReactWrapper {
+): (tx: any) => RenderResult {
return function createDescriptionWrapper(tx: any) {
- return createWrapper(, i18nConfig)
+ return renderComponent(, i18nConfig)
}
}
-export function createSimpleWrapperFactory(
+export function createSimpleRenderFactory(
Simple: TransactionSimpleComponent,
i18nConfig?: i18n,
-): (tx: any) => ReactWrapper {
+): (tx: any) => RenderResult {
return function createSimpleWrapper(tx: any) {
const data = summarizeTransaction(tx, true)
- return createWrapper(, i18nConfig)
+ return renderComponent(, i18nConfig)
}
}
-export function createTableDetailWrapperFactory(
+export function createTableDetailRenderFactory(
TableDetail: TransactionTableDetailComponent,
i18nConfig?: i18n,
-): (tx: any) => ReactWrapper {
+): (tx: any) => RenderResult {
return function createTableDetailWrapper(tx: any) {
const data = summarizeTransaction(tx, true)
- return createWrapper(
+ return renderComponent(
,
i18nConfig,
)
diff --git a/src/containers/shared/components/Transaction/test/expectations.ts b/src/containers/shared/components/Transaction/test/expectations.ts
index 01827b83e..1240c471b 100644
--- a/src/containers/shared/components/Transaction/test/expectations.ts
+++ b/src/containers/shared/components/Transaction/test/expectations.ts
@@ -1,21 +1,8 @@
-import { ReactWrapper } from 'enzyme'
+export const expectSimpleRowLabel = (screen: any, key: string, text: string) =>
+ expect(screen.getByTestId(key)).toHaveTextContent(text)
-const getSelector = (selector: string) =>
- selector.indexOf('.') === 0 ? selector : `[data-testid="${selector}"]`
+export const expectSimpleRowText = (screen: any, key: string, text: string) =>
+ expect(screen.getByTestId(key)).toHaveTextContent(text)
-export const expectSimpleRowLabel = (
- wrapper: ReactWrapper>,
- key: string,
- text: string,
-) => expect(wrapper.find(`${getSelector(key)} .label`)).toHaveText(text)
-
-export const expectSimpleRowText = (
- wrapper: ReactWrapper>,
- key: string,
- text: string,
-) => expect(wrapper.find(`${getSelector(key)} .value`)).toHaveText(text)
-
-export const expectSimpleRowNotToExist = (
- wrapper: ReactWrapper>,
- key: string,
-) => expect(wrapper.find(`${getSelector(key)}`)).not.toExist()
+export const expectSimpleRowNotToExist = (screen: any, key: string) =>
+ expect(screen.queryByTestId(key)).toBeNull()
diff --git a/src/containers/shared/components/Transaction/test/index.ts b/src/containers/shared/components/Transaction/test/index.ts
index 0d1b90d58..b226bafbf 100644
--- a/src/containers/shared/components/Transaction/test/index.ts
+++ b/src/containers/shared/components/Transaction/test/index.ts
@@ -1,2 +1,2 @@
-export * from './createWrapperFactory'
+export * from './createRenderFactory'
export * from './expectations'
diff --git a/src/containers/shared/components/TransactionActionIcon/TransactionActionIcon.tsx b/src/containers/shared/components/TransactionActionIcon/TransactionActionIcon.tsx
index 7873d177e..b21ffb36d 100644
--- a/src/containers/shared/components/TransactionActionIcon/TransactionActionIcon.tsx
+++ b/src/containers/shared/components/TransactionActionIcon/TransactionActionIcon.tsx
@@ -17,12 +17,12 @@ export const TransactionActionIcon = ({
type,
}: TransactionActionIconProps) => {
const icons: Record = {
- [TransactionAction.CANCEL]: ,
- [TransactionAction.CREATE]: ,
- [TransactionAction.FINISH]: ,
- [TransactionAction.MODIFY]: ,
- [TransactionAction.SEND]: ,
- [TransactionAction.UNKNOWN]: ,
+ [TransactionAction.CANCEL]: ,
+ [TransactionAction.CREATE]: ,
+ [TransactionAction.FINISH]: ,
+ [TransactionAction.MODIFY]: ,
+ [TransactionAction.SEND]: ,
+ [TransactionAction.UNKNOWN]: ,
}
let icon = type && icons[getAction(type)]
diff --git a/src/containers/shared/components/TransactionActionIcon/test/TransactionActionIcon.test.tsx b/src/containers/shared/components/TransactionActionIcon/test/TransactionActionIcon.test.tsx
index a17f0e317..309f530c4 100644
--- a/src/containers/shared/components/TransactionActionIcon/test/TransactionActionIcon.test.tsx
+++ b/src/containers/shared/components/TransactionActionIcon/test/TransactionActionIcon.test.tsx
@@ -1,35 +1,27 @@
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import { TransactionActionIcon } from '../TransactionActionIcon'
import { TransactionAction } from '../../Transaction/types'
-import TransactionCreateIcon from '../TransactionCreateIcon.svg'
-import TransactionSendIcon from '../TransactionSendIcon.svg'
-import TransactionUnknownIcon from '../TransactionUnknownIcon.svg'
describe('TransactionActionIcon', () => {
+ afterEach(cleanup)
it('renders with an action specified ', () => {
- const wrapper = mount(
- ,
- )
- expect(wrapper).toContainReact()
- wrapper.unmount()
+ render()
+ expect(screen.getByTitle('tx-create')).toBeDefined()
})
it('renders with type specified ', () => {
- const wrapper = mount()
- expect(wrapper).toContainReact()
- wrapper.unmount()
+ render()
+ expect(screen.getByTitle('tx-send')).toBeDefined()
})
it('renders with type specified that is not defined', () => {
- const wrapper = mount()
- expect(wrapper).toContainReact()
- wrapper.unmount()
+ render()
+ expect(screen.getByTitle('tx-unknown')).toBeDefined()
})
it('renders with no action or type', () => {
// @ts-expect-error
- const wrapper = mount()
- expect(wrapper).toContainReact()
- wrapper.unmount()
+ render()
+ expect(screen.getByTitle('tx-unknown')).toBeDefined()
})
})
diff --git a/src/containers/shared/components/TransactionTable/TransactionTable.tsx b/src/containers/shared/components/TransactionTable/TransactionTable.tsx
index 6d498d5ab..7e32a0baf 100644
--- a/src/containers/shared/components/TransactionTable/TransactionTable.tsx
+++ b/src/containers/shared/components/TransactionTable/TransactionTable.tsx
@@ -39,10 +39,13 @@ export const TransactionTable: TransactionTableComponent = ({
return (
<>
-
+
-
{hasTokensColumn && (
-
{t('token')}
+
+ {' '}
+ {t('token')}{' '}
+
)}
{t('account')}
{t('transaction_type')}
@@ -50,7 +53,10 @@ export const TransactionTable: TransactionTableComponent = ({
{t('transactions.date_header')}
{!transactions || (!loading && transactions.length === 0) ? (
-
+
{emptyMessage || t('no_transactions_message')}
) : (
diff --git a/src/containers/shared/components/TransactionTable/TransactionTableRow.tsx b/src/containers/shared/components/TransactionTable/TransactionTableRow.tsx
index 4594c62de..b4384a4d5 100644
--- a/src/containers/shared/components/TransactionTable/TransactionTableRow.tsx
+++ b/src/containers/shared/components/TransactionTable/TransactionTableRow.tsx
@@ -35,6 +35,7 @@ export const TransactionTableRow = ({ tx, hasTokensColumn }: Props) => {
className={`transaction-li anchor-mask tx-type ${tx.type} ${
success ? 'success' : 'fail'
}`}
+ title="tx-row"
>
{
{date}
{tx.details && (
-
+
)}
diff --git a/src/containers/shared/components/TransactionTable/test/TransactionTable.test.js b/src/containers/shared/components/TransactionTable/test/TransactionTable.test.js
index 734e4f0d5..a89ef5555 100644
--- a/src/containers/shared/components/TransactionTable/test/TransactionTable.test.js
+++ b/src/containers/shared/components/TransactionTable/test/TransactionTable.test.js
@@ -1,4 +1,4 @@
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import { I18nextProvider } from 'react-i18next'
import { BrowserRouter } from 'react-router-dom'
import { QueryClientProvider } from 'react-query'
@@ -10,14 +10,15 @@ import { queryClient } from '../../../QueryClient'
const loadMore = jest.fn()
describe('Transaction Table container', () => {
- const createWrapper = (
+ afterEach(cleanup)
+ const renderComponent = (
transactions = [],
emptyMessage = undefined,
loading = false,
onLoadMore = loadMore,
hasAdditionalResults = false,
) =>
- mount(
+ render(
@@ -34,70 +35,40 @@ describe('Transaction Table container', () => {
)
it('renders without crashing', () => {
- const wrapper = createWrapper()
- wrapper.unmount()
+ renderComponent()
})
it('renders multi-page content', () => {
- const wrapper = createWrapper(
- mockTx.transactions,
- undefined,
- false,
- loadMore,
- false,
- )
+ renderComponent(mockTx.transactions, undefined, false, loadMore, false)
- expect(wrapper.find('.transaction-table').length).toBe(1)
- expect(wrapper.find('.upper').length).toBe(3)
- expect(wrapper.find('.details').length).toBe(2)
- expect(wrapper.find('.load-more-btn').length).toEqual(0)
- wrapper.unmount()
+ expect(screen.queryByTitle('transaction-table')).toBeDefined()
+ expect(screen.getAllByTitle('tx-row')).toHaveLength(3)
+ expect(screen.getAllByTitle('tx-details')).toHaveLength(2)
+ expect(screen.queryByRole('button')).toBeNull()
})
it('renders single-page content', () => {
- const wrapper = createWrapper(
- mockTx.transactions,
- undefined,
- false,
- loadMore,
- true,
- )
- expect(wrapper.find('.transaction-table').length).toBe(1)
- expect(wrapper.find('.upper').length).toBe(3)
- expect(wrapper.find('.details').length).toBe(2)
- expect(wrapper.find('.load-more-btn').length).toEqual(1)
- wrapper.unmount()
+ renderComponent(mockTx.transactions, undefined, false, loadMore, true)
+ expect(screen.queryByTitle('transaction-table')).toBeDefined()
+ expect(screen.getAllByTitle('tx-row')).toHaveLength(3)
+ expect(screen.getAllByTitle('tx-details')).toHaveLength(2)
+ expect(screen.queryByRole('button')).toBeDefined()
})
it('renders without details', () => {
- const wrapper = createWrapper(
- mockTx.transactions,
- undefined,
- false,
- loadMore,
- true,
- )
- expect(wrapper.find('.transaction-table').length).toBe(1)
- expect(wrapper.find('.upper').length).toBe(3)
- expect(wrapper.find('.details').length).toBe(2)
- wrapper.unmount()
+ renderComponent(mockTx.transactions, undefined, false, loadMore, true)
+ expect(screen.queryByTitle('transaction-table')).toBeDefined()
+ expect(screen.getAllByTitle('tx-row')).toHaveLength(3)
+ expect(screen.getAllByTitle('tx-details')).toHaveLength(2)
})
it('renders loader', () => {
- const wrapper = createWrapper(
- mockTx.transactions,
- undefined,
- true,
- loadMore,
- false,
- )
- expect(wrapper.find('.loader').length).toBe(1)
- wrapper.unmount()
+ renderComponent(mockTx.transactions, undefined, true, loadMore, false)
+ expect(screen.queryByTitle('loader')).toBeDefined()
})
it('renders empty message', () => {
- const wrapper = createWrapper([], undefined, false, loadMore, false)
- expect(wrapper.find('.empty-transactions-message').length).toBe(1)
- wrapper.unmount()
+ renderComponent([], undefined, false, loadMore, false)
+ expect(screen.queryByTitle('empty-transactions-message')).toBeDefined()
})
})
diff --git a/src/containers/shared/components/TxLabel.tsx b/src/containers/shared/components/TxLabel.tsx
index 8533598cf..c18c1aac2 100644
--- a/src/containers/shared/components/TxLabel.tsx
+++ b/src/containers/shared/components/TxLabel.tsx
@@ -11,7 +11,10 @@ export const TxLabel = (props: Props) => {
const { t } = useTranslation()
const { type } = props
return (
-
+
{t(`transaction_type_name`, { context: type, defaultValue: type })}
diff --git a/src/containers/shared/components/TxStatus.tsx b/src/containers/shared/components/TxStatus.tsx
index 7fdc70103..7ec374b56 100644
--- a/src/containers/shared/components/TxStatus.tsx
+++ b/src/containers/shared/components/TxStatus.tsx
@@ -27,7 +27,7 @@ export const TxStatus = ({ shorthand = false, status }: TxStatusProps) => {
const Success = () => (
-
+
{!shorthand && {t('success')}}
@@ -39,7 +39,7 @@ export const TxStatus = ({ shorthand = false, status }: TxStatusProps) => {
const content = (
<>
-
+
{!shorthand && {t('fail')}}
diff --git a/src/containers/shared/components/test/Amount.test.tsx b/src/containers/shared/components/test/Amount.test.tsx
index a1c226587..e00b9b171 100644
--- a/src/containers/shared/components/test/Amount.test.tsx
+++ b/src/containers/shared/components/test/Amount.test.tsx
@@ -152,7 +152,6 @@ describe('Amount', () => {
isMPT: true,
}
renderComponent()
- screen.debug()
expect(screen.getByTestId('amount-localized')).toHaveTextContent(
'1,043.001',
diff --git a/src/containers/shared/components/test/DomainLink.test.tsx b/src/containers/shared/components/test/DomainLink.test.tsx
index 71e589e8a..bb0096fc5 100644
--- a/src/containers/shared/components/test/DomainLink.test.tsx
+++ b/src/containers/shared/components/test/DomainLink.test.tsx
@@ -1,64 +1,67 @@
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import DomainLink from '../DomainLink'
+const checkDomain = (
+ param: string,
+ expectedText: string,
+ expectedDomain: string,
+ decode: boolean = false,
+) => {
+ const { container } = render()
+ expect(container).toHaveTextContent(expectedText)
+ expect(screen.getByText(expectedText)).toHaveAttribute('href', expectedDomain)
+}
+
describe('DomainLink', () => {
+ afterEach(cleanup)
it('handles domain link with only domain parameter', () => {
- const wrapper = mount()
- expect(wrapper.find('a').props().className).toEqual('domain')
- expect(wrapper.find('a').text()).toEqual('bithomp.com')
- expect(wrapper.find('a').props().href).toEqual('https://bithomp.com')
- wrapper.unmount()
+ checkDomain('bithomp.com', 'bithomp.com', 'https://bithomp.com')
})
it('handles domain link with decoded domain parameter', () => {
- const wrapper = mount(
- ,
+ checkDomain(
+ '736F6C6F67656E69632E636F6D',
+ 'sologenic.com',
+ 'https://sologenic.com',
+ true,
)
- expect(wrapper.find('a').props().className).toEqual('domain')
- expect(wrapper.find('a').text()).toEqual('sologenic.com')
- expect(wrapper.find('a').props().href).toEqual('https://sologenic.com')
- wrapper.unmount()
})
it('handles domain link with domain parameter and classname', () => {
- const wrapper = mount()
- expect(wrapper.find('a').props().className).toEqual('domain test')
- expect(wrapper.find('a').text()).toEqual('bithomp.com')
- expect(wrapper.find('a').props().href).toEqual('https://bithomp.com')
- wrapper.unmount()
+ const { container } = render(
+ ,
+ )
+ expect(container).toHaveTextContent('bithomp.com')
+ expect(screen.getByText('bithomp.com')).toHaveAttribute(
+ 'href',
+ 'https://bithomp.com',
+ )
+ expect(screen.getByText('bithomp.com')).toHaveClass('test')
})
it('handles domain link with decoded domain parameter and classname', () => {
- const wrapper = mount(
- ,
+ checkDomain(
+ '736F6C6F67656E69632E636F6D',
+ 'sologenic.com',
+ 'https://sologenic.com',
+ true,
)
- expect(wrapper.find('a').props().className).toEqual('domain test')
- expect(wrapper.find('a').text()).toEqual('sologenic.com')
- expect(wrapper.find('a').props().href).toEqual('https://sologenic.com')
- wrapper.unmount()
})
it('handles domain link with domain provided in HEX-encoded format', () => {
- const url = 'https://example.com'
- const urlInHex = '68747470733A2F2F6578616D706C652E636F6D'
- const wrapper = mount()
- expect(wrapper.find('a').props().className).toEqual('domain')
- expect(wrapper.find('a').text()).toEqual(url)
- expect(wrapper.find('a').props().href).toEqual(url)
- wrapper.unmount()
+ checkDomain(
+ '68747470733A2F2F6578616D706C652E636F6D',
+ 'https://example.com',
+ 'https://example.com',
+ true,
+ )
})
it('handles IPFS domain link', () => {
- const wrapper = mount()
- expect(wrapper.find('a').props().className).toEqual('domain')
- expect(wrapper.find('a').text()).toEqual('ipfs://random/metadata.json')
- expect(wrapper.find('a').props().href).toEqual(
+ checkDomain(
+ 'ipfs://random/metadata.json',
+ 'ipfs://random/metadata.json',
'https://ipfs.io/ipfs/random/metadata.json',
)
- wrapper.unmount()
})
})
diff --git a/src/containers/shared/components/test/Loader.test.tsx b/src/containers/shared/components/test/Loader.test.tsx
index c5fceed6c..20a8c6b28 100644
--- a/src/containers/shared/components/test/Loader.test.tsx
+++ b/src/containers/shared/components/test/Loader.test.tsx
@@ -1,16 +1,16 @@
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import { I18nextProvider } from 'react-i18next'
import i18n from '../../../../i18n/testConfig'
import { Loader } from '../Loader'
describe('Loader', () => {
+ afterEach(cleanup)
it('renders correctly ', () => {
- const wrapper = mount(
+ render(
,
)
- expect(wrapper.find('.loader').length).toEqual(1)
- wrapper.unmount()
+ expect(screen.queryByTitle('loader')).toBeDefined()
})
})
diff --git a/src/containers/shared/test/txDetails.test.js b/src/containers/shared/components/test/TxDetails.test.js
similarity index 56%
rename from src/containers/shared/test/txDetails.test.js
rename to src/containers/shared/components/test/TxDetails.test.js
index 85724f519..699c67e78 100644
--- a/src/containers/shared/test/txDetails.test.js
+++ b/src/containers/shared/components/test/TxDetails.test.js
@@ -1,14 +1,15 @@
-import { mount } from 'enzyme'
import { I18nextProvider } from 'react-i18next'
import { BrowserRouter as Router } from 'react-router-dom'
-import i18n from '../../../i18n/testConfig'
-import EnableAmendment from '../../Transactions/test/mock_data/EnableAmendment.json'
-import { TxDetails } from '../components/TxDetails'
-import summarize from '../../../rippled/lib/txSummary'
+import { cleanup, render } from '@testing-library/react'
+import i18n from '../../../../i18n/testConfig'
+import EnableAmendment from '../../../Transactions/test/mock_data/EnableAmendment.json'
+import { TxDetails } from '../TxDetails'
+import summarize from '../../../../rippled/lib/txSummary'
describe('TxDetails', () => {
- const createWrapper = (tx) =>
- mount(
+ afterEach(cleanup)
+ const renderComponent = (tx) =>
+ render(
{
)
it('renders EnableAmendment without crashing', () => {
- const wrapper = createWrapper(EnableAmendment)
- wrapper.unmount()
+ renderComponent(EnableAmendment)
})
})
diff --git a/src/containers/shared/components/test/TxLabel.test.tsx b/src/containers/shared/components/test/TxLabel.test.tsx
index 46617e43d..04a3ccf07 100644
--- a/src/containers/shared/components/test/TxLabel.test.tsx
+++ b/src/containers/shared/components/test/TxLabel.test.tsx
@@ -1,34 +1,34 @@
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import { I18nextProvider } from 'react-i18next'
import { TxLabel } from '../TxLabel'
-import TransactionCancelIcon from '../TransactionActionIcon/TransactionCancelIcon.svg'
-import TransactionSendIcon from '../TransactionActionIcon/TransactionSendIcon.svg'
-import TransactionUnknownIcon from '../TransactionActionIcon/TransactionUnknownIcon.svg'
import i18n from '../../../../i18n/testConfigEnglish'
describe('TxLabel', () => {
- const createWapper = (component: any) =>
- mount({component})
+ afterEach(cleanup)
+ const renderComponent = (component: any) =>
+ render({component})
- it('renders with an action specified ', () => {
- let wrapper = createWapper()
- expect(wrapper.find('.tx-category-PAYMENT')).toExist()
- expect(wrapper).toContainReact()
- expect(wrapper.find('.tx-type-name')).toHaveText('Payment')
- wrapper.unmount()
+ it('renders with an action specified', () => {
+ const { container } = renderComponent()
- wrapper = createWapper()
- expect(wrapper.find('.tx-category-DEX')).toExist()
- expect(wrapper).toContainReact()
- expect(wrapper.find('.tx-type-name')).toHaveText('Offer Cancel')
- wrapper.unmount()
+ expect(screen.getByTitle('tx-label')).toHaveClass('tx-category-PAYMENT')
+ expect(screen.queryByTitle('tx-send')).toBeDefined()
+ expect(container).toHaveTextContent('Payment')
+ })
+
+ it('renders with an action specified 2', () => {
+ const { container } = renderComponent()
+
+ expect(screen.getByTitle('tx-label')).toHaveClass('tx-category-DEX')
+ expect(screen.queryByTitle('tx-cancel')).toBeDefined()
+ expect(container).toHaveTextContent('Offer Cancel')
})
it('renders with type that is not defined', () => {
- const wrapper = createWapper()
- expect(wrapper.find('.tx-category-UNKNOWN')).toExist()
- expect(wrapper).toContainReact()
- expect(wrapper.find('.tx-type-name')).toHaveText('WooCreate')
- wrapper.unmount()
+ const { container } = renderComponent()
+
+ expect(screen.getByTitle('tx-label')).toHaveClass('tx-category-UNKNOWN')
+ expect(screen.queryByTitle('tx-unknown')).toBeDefined()
+ expect(container).toHaveTextContent('WooCreate')
})
})
diff --git a/src/containers/shared/components/test/TxStatus.test.tsx b/src/containers/shared/components/test/TxStatus.test.tsx
index e5c669f6a..4481be255 100644
--- a/src/containers/shared/components/test/TxStatus.test.tsx
+++ b/src/containers/shared/components/test/TxStatus.test.tsx
@@ -1,50 +1,51 @@
import { ReactElement } from 'react'
import { I18nextProvider } from 'react-i18next'
import { MemoryRouter } from 'react-router'
-import { mount } from 'enzyme'
+import { cleanup, render, screen } from '@testing-library/react'
import i18n from '../../../../i18n/testConfigEnglish'
import { TxStatus } from '../TxStatus'
describe('TxStatus', () => {
- const createWrapper = (component: ReactElement) =>
- mount(
+ afterEach(cleanup)
+ const renderComponent = (component: ReactElement) =>
+ render(
{component}
,
)
it('renders success correctly ', () => {
- const wrapper = createWrapper()
- expect(wrapper.find('.status')).toHaveText('Success')
- expect(wrapper.find('svg.success')).toExist()
- wrapper.unmount()
+ const { container } = renderComponent()
+ expect(container).toHaveTextContent('Success')
+ expect(screen.getByTitle('status')).toBeDefined()
+ expect(screen.getByTitle('status')).toHaveClass('success')
})
it('renders success correctly without message in shorthand mode', () => {
- const wrapper = createWrapper()
- expect(wrapper.find('.status')).not.toHaveText('Success')
- expect(wrapper.find('svg.success')).toExist()
- wrapper.unmount()
+ const { container } = renderComponent(
+ ,
+ )
+ expect(container).not.toHaveTextContent('Success')
+ expect(screen.getByTitle('status')).toBeDefined()
+ expect(screen.getByTitle('status')).toHaveClass('success')
})
- it('renders failure correctly ', () => {
- const wrapper = createWrapper()
- expect(wrapper.find('.status-message')).toHaveText('Fail')
- expect(wrapper.find('.status-code')).toHaveText('tecPATH_DRY')
- expect(wrapper.find('svg.fail')).toExist()
- expect(wrapper.find('a')).toHaveProp(
+ it('renders failure correctly', () => {
+ renderComponent()
+ expect(screen.getByText('Fail')).toBeDefined()
+ expect(screen.getByTitle('status')).toBeDefined()
+ expect(screen.getByTitle('status')).toHaveClass('fail')
+ expect(screen.getByTitle('Fail - tecPATH_DRY')).toHaveAttribute(
'href',
'https://xrpl.org/tec-codes.html#tecPATH_DRY',
)
- wrapper.unmount()
})
it('renders failure correctly without message in shorthand mode ', () => {
- const wrapper = createWrapper()
- expect(wrapper.find('.status-message')).not.toExist()
- expect(wrapper.find('.status-code')).toHaveText('tecPATH_DRY')
- expect(wrapper.find('svg.fail')).toExist()
- expect(wrapper.find('a')).not.toExist() // Not a link in shorthand
- wrapper.unmount()
+ renderComponent()
+ expect(screen.queryByText('Fail')).toBeNull()
+ expect(screen.getByTitle('status')).toBeDefined()
+ expect(screen.getByTitle('status')).toHaveClass('fail')
+ expect(screen.getByTitle('Fail')).not.toHaveAttribute('href') // Not a link in shorthand
})
})
diff --git a/src/containers/shared/components/test/TxToken.test.tsx b/src/containers/shared/components/test/TxToken.test.tsx
index e76931f7d..2f987bc2d 100644
--- a/src/containers/shared/components/test/TxToken.test.tsx
+++ b/src/containers/shared/components/test/TxToken.test.tsx
@@ -1,4 +1,4 @@
-import { mount } from 'enzyme'
+import { cleanup, render } from '@testing-library/react'
import { I18nextProvider } from 'react-i18next'
import i18n from '../../../../i18n/testConfigEnglish'
import TxToken from '../TxToken'
@@ -11,34 +11,35 @@ import paymentMock from '../Transaction/Payment/test/mock_data/Payment.json'
import summarizeTransaction from '../../../../rippled/lib/txSummary'
describe('TxToken', () => {
- const createWrapper = (transaction: any) =>
- mount(
+ afterEach(cleanup)
+ const renderComponent = (transaction: any) =>
+ render(
,
)
it('to render for a Payment transaction', () => {
- const wrapper = createWrapper(paymentMock)
+ const { container } = renderComponent(paymentMock)
- expect(wrapper).toHaveText('\uE900 XRP')
+ expect(container).toHaveTextContent('\uE900 XRP')
})
it('to render for a NON Payment transaction with only issued currency', () => {
- const wrapper = createWrapper(withdrawUSDMock)
+ const { container } = renderComponent(withdrawUSDMock)
- expect(wrapper).toHaveText('USD')
+ expect(container).toHaveTextContent('USD')
})
it('to render for a NON Payment transaction with only XRP', () => {
- const wrapper = createWrapper(withdrawXRPMock)
+ const { container } = renderComponent(withdrawXRPMock)
- expect(wrapper).toHaveText('\uE900 XRP')
+ expect(container).toHaveTextContent('\uE900 XRP')
})
it('to render for a NON Payment transaction with multiple amounts', () => {
- const wrapper = createWrapper(withdrawMock)
+ const { container } = renderComponent(withdrawMock)
- expect(wrapper).toHaveText('\uE900 XRP and USD')
+ expect(container).toHaveTextContent('\uE900 XRP and USD')
})
})
diff --git a/src/containers/shared/test/notification.test.tsx b/src/containers/shared/test/notification.test.tsx
deleted file mode 100644
index ce722ed1d..000000000
--- a/src/containers/shared/test/notification.test.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { mount } from 'enzyme'
-import { Notification } from '../components/Notification'
-
-describe('Notification', () => {
- it('renders without crashing', () => {
- const wrapper = mount(
- ,
- )
- wrapper.unmount()
- })
-
- it('dissapears', (done) => {
- const wrapper = mount(
- ,
- )
- expect(wrapper.html()).toBe(
- 'boo!
',
- )
-
- setTimeout(() => {
- wrapper.update()
- expect(wrapper.html()).toBe(null)
- wrapper.unmount()
- done()
- }, 200)
- })
-})