From dd811dcd6ae0d29714aaf3affc15742269c20591 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 5 Jul 2024 11:47:58 -0400 Subject: [PATCH] update new tests --- .../Transaction/OracleDelete/TableDetail.tsx | 2 +- .../test/OracleDeleteSimple.test.tsx | 11 ++--- .../test/OracleDeleteTableDetail.test.tsx | 13 +++--- .../Transaction/OracleSet/TableDetail.tsx | 44 +++++++++---------- .../OracleSet/test/OracleSetSimple.test.tsx | 19 ++++---- .../test/OracleSetTableDetail.test.tsx | 11 ++--- 6 files changed, 51 insertions(+), 49 deletions(-) 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() }) })