Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/transaction info row #408

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ module.exports = {
'\\.graphql$': 'jest-transform-graphql',
'\\.spec.ts?$': 'ts-jest'
},
moduleNameMapper: {
"\\.(css|less|scss)$": "<rootDir>/source/__mocks__/styleMock.js"
}
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
"@types/chroma-js": "1.4.3",
"@types/classnames": "2.2.9",
"@types/debug": "4.1.4",
"@types/enzyme": "^3.10.8",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/graphql": "14.2.0",
"@types/jest": "26.0.3",
"@types/lodash": "4.14.119",
Expand Down Expand Up @@ -120,6 +122,8 @@
"cypress": "4.12.1",
"dotenv": "8.0.0",
"dotenv-webpack": "1.7.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"husky": "3.0.3",
"jest": "26.1.0",
"jest-transform-graphql": "2.1.0",
Expand Down
1 change: 1 addition & 0 deletions source/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
4 changes: 4 additions & 0 deletions source/config/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { RetryPromise } from 'promise-exponential-retry';
import waitForExpect from 'wait-for-expect';
import { graphqlClient } from '../lib/graphql/graphqlClient';
import './mobx.config';

configure({ adapter: new Adapter() });

beforeAll(async () => {
jest.setTimeout(15000);
waitForExpect.defaults.timeout = 9000;
Expand Down
41 changes: 14 additions & 27 deletions source/features/transactions/components/TransactionInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
IWithdrawal,
} from '../types';
import styles from './TransactionInfo.module.scss';
import { TransactionInfoRow } from './TransactionInfoRow/TransactionInfoRow';
import TokenList from './TransactionTokenList';

dayjs.extend(relativeTime);
Expand Down Expand Up @@ -121,19 +122,13 @@ const TransactionInfo = (props: ITransactionInfoProps) => {
)}

{/* ===== RECEIVED TIME ===== */}

<div className={styles.row}>
<div className={styles.label}>
{translate('transaction.receivedTime')}
</div>
<div className={styles.value}>
&gt; {dayjs().utc().to(includedAtUtc)} (
{includedAtUtc.format('YYYY-MM-DD HH:mm:ss')} UTC)
</div>
</div>
<TransactionInfoRow
label={translate('transaction.receivedTime')}
value={`> ${dayjs().utc().to(includedAtUtc)}
(${includedAtUtc.format('YYYY-MM-DD HH:mm:ss')} UTC)`}
/>

{/* ===== INCLUDED IN ===== */}

{props.showDetails && (
<div className={styles.row}>
<div className={styles.label}>
Expand Down Expand Up @@ -248,26 +243,18 @@ const TransactionInfo = (props: ITransactionInfoProps) => {
</div>

{/* ===== DEPOSIT ===== */}
{props.deposit !== '0' && (
<div className={styles.row}>
<div className={styles.label}>{translate(depositLabel)}</div>
<div className={styles.value}>
{Math.abs(parseInt(props.deposit))} ADA
</div>
</div>
)}
<TransactionInfoRow
label={translate(depositLabel)}
value={`${Math.abs(parseInt(props.deposit))} ADA`}
/>

{/* ===== TOTAL OUTPUT ===== */}

<div className={styles.row}>
<div className={styles.label}>
{translate('transaction.totalOutput')}
</div>
<div className={styles.value}>{props.totalOutput} ADA</div>
</div>
<TransactionInfoRow
label={translate('transaction.totalOutput')}
value={`${props.totalOutput} ADA`}
/>

{/* ===== CONFIRMATIONS ===== */}

{props.showDetails && (
<div className={styles.row}>
<div className={styles.label}>{translate('transaction.fee')}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { shallow } from 'enzyme';
import React from 'react';
import { TransactionInfoRow } from './TransactionInfoRow';

describe('<TransactionInfoRow/>', () => {
it('deposit :renders label with value', () => {
const label = 'Deposit';
const value = '2 ADA';
const wrapper = shallow(<TransactionInfoRow label={label} value={value} />);
expect(wrapper.find('[data-testid="label"]').text()).toEqual(label);
expect(wrapper.find('[data-testid="value"]').text()).toEqual(value);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import styles from '../TransactionInfo.module.scss';

interface ITransactionInfoRowProps {
label: string;
value: string;
}

export const TransactionInfoRow = (props: ITransactionInfoRowProps) => {
return (
<div className={styles.row}>
<div data-testid="label" className={styles.label}>
{props.label}
</div>
<div data-testid="value" className={styles.value}>
{props.value}
</div>
</div>
);
};
1 change: 1 addition & 0 deletions styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};