Skip to content

Commit

Permalink
update new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Jul 5, 2024
1 parent 904fb14 commit a2cf6d2
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Simple: TransactionSimpleComponent = ({
const { t } = useTranslation()
const { OracleDocumentID } = data.instructions
return (
<SimpleRow label={t('oracle_document_id')} data-test="oracle-document-id">
<SimpleRow label={t('oracle_document_id')} data-testid="oracle-document-id">
{OracleDocumentID}
</SimpleRow>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const TableDetail = ({
}: TransactionTableDetailProps<OracleDelete>) => {
const { t } = useTranslation()
return (
<div className="oracle-document-id">
<div className="oracle-document-id" data-testid="oracle-document-id">
<span className="label">{t('oracle_document_id')}: </span>
<span className="case-sensitive">{tx.OracleDocumentID}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -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')
})
})
Original file line number Diff line number Diff line change
@@ -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`,
)
})
})
17 changes: 10 additions & 7 deletions src/containers/shared/components/Transaction/OracleSet/Simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ export const Simple: TransactionSimpleComponent = ({
} = data.instructions
return (
<>
<SimpleRow label={t('oracle_document_id')} data-test="oracle-document-id">
<SimpleRow
label={t('oracle_document_id')}
data-testid="oracle-document-id"
>
{oracleDocumentID}
</SimpleRow>

{provider && (
<SimpleRow label={t('provider')} data-test="provider">
<SimpleRow label={t('provider')} data-testid="provider">
{provider}
</SimpleRow>
)}

{uri && (
<SimpleRow label={t('uri')} data-test="uri">
<SimpleRow label={t('uri')} data-testid="uri">
{uri}
</SimpleRow>
)}

<SimpleRow label={t('last_update_time')} data-test="last-update-time">
<SimpleRow label={t('last_update_time')} data-testid="last-update-time">
{localizeDate(
new Date(lastUpdateTime * MILLIS_PER_SECOND),
language,
Expand All @@ -47,14 +50,14 @@ export const Simple: TransactionSimpleComponent = ({
</SimpleRow>

{assetClass && (
<SimpleRow label={t('asset_class')} data-test="asset-class">
<SimpleRow label={t('asset_class')} data-testid="asset-class">
{assetClass}
</SimpleRow>
)}

<SimpleRow label={t('trading_pairs')} data-test="trading-pairs">
<SimpleRow label={t('trading_pairs')} data-testid="trading-pairs">
{priceDataSeries.map((priceDataObj) => (
<div className="amount list" data-test="amount">
<div className="amount list" data-testid="amount">
{priceDataObj.assetPrice ?? t('deleted')}
<div className="one-line">
<Currency currency={priceDataObj.baseAsset} />/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,31 @@ export const TableDetail = ({
const { t } = useTranslation()
const language = useLanguage()
return (
<>
<div data-testid="table-detail">
<div className="oracle-document-id">
<span className="label">{t('oracle_document_id')}: </span>
<span className="case-sensitive">{tx.oracleDocumentID}</span>
</div>
<>
{tx.provider && (
<>
<span className="label">{t('provider')}: </span>
<span className="case-sensitive">{tx.provider}</span>
</>
)}
{tx.assetClass && (
<>
<span className="label">{t('asset_class')}: </span>
<span className="case-sensitive">{tx.assetClass}</span>
</>
)}
{tx.provider && (
<>
<span className="label">{t('provider')}: </span>
<span className="case-sensitive">{tx.provider}</span>
</>
)}
{tx.assetClass && (
<>
<span className="label">{t('last_update_time')}: </span>
<span className="case-sensitive">
{localizeDate(
new Date(tx.lastUpdateTime * MILLIS_PER_SECOND),
language,
DATE_OPTIONS,
)}
</span>
<span className="label">{t('asset_class')}: </span>
<span className="case-sensitive">{tx.assetClass}</span>
</>
</>
)}
<span className="label">{t('last_update_time')}: </span>
<span className="case-sensitive">
{localizeDate(
new Date(tx.lastUpdateTime * MILLIS_PER_SECOND),
language,
DATE_OPTIONS,
)}
</span>
<div className="trading-pair">
<span className="label">{t('trading_pairs')}: </span>
{tx.priceDataSeries.map((priceDataObj, index) => (
Expand All @@ -58,6 +54,6 @@ export const TableDetail = ({
</>
))}
</div>
</>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -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()
})
})
Original file line number Diff line number Diff line change
@@ -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()
})
})

0 comments on commit a2cf6d2

Please sign in to comment.