Compare commits

..
7 changed files with 137724 additions and 137794 deletions
+1 -15
View File
@@ -1,17 +1,3 @@
{
"hosts": [
"https://vega-data-graphql.chorus.one/query",
"https://vega.xprv.io/datanode/query",
"http://nala.mainnet.vega.community:3008/query",
"http://commodum.mainnet.vega.community:3008/query",
"http://lovali.mainnet.vega.community:3008/query",
"http://b-harvest.mainnet.vega.community:3008/query",
"http://staking-facilities.mainnet.vega.community:3008/query",
"http://figment.mainnet.vega.community:3008/query",
"http://nodes-guru.mainnet.vega.community:3008/query",
"http://p2p.mainnet.vega.community:3008/query",
"http://rockaway.mainnet.vega.community:3008/query",
"http://greenfield-one.mainnet.vega.community:3008/query",
"http://ryabina.mainnet.vega.community:3008/query"
]
"hosts": ["https://vega.xprv.io/datanode/query"]
}
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -1,10 +1,11 @@
import React from 'react';
import {
PriceCell,
VolCell,
Vol,
CumulativeVol,
addDecimalsFormatNumber,
VolumeType,
addDecimal,
} from '@vegaprotocol/react-helpers';
interface OrderbookRowProps {
@@ -41,17 +42,17 @@ export const OrderbookRow = React.memo(
}: OrderbookRowProps) => {
return (
<>
<VolCell
<Vol
testId={`bid-vol-${price}`}
value={bid}
valueFormatted={addDecimalsFormatNumber(bid, positionDecimalPlaces)}
valueFormatted={addDecimal(bid, positionDecimalPlaces)}
relativeValue={relativeBid}
type={VolumeType.bid}
/>
<VolCell
<Vol
testId={`ask-vol-${price}`}
value={ask}
valueFormatted={addDecimalsFormatNumber(ask, positionDecimalPlaces)}
valueFormatted={addDecimal(ask, positionDecimalPlaces)}
relativeValue={relativeAsk}
type={VolumeType.ask}
/>
@@ -1,4 +1,6 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { NumericCell } from './numeric-cell';
describe('NumericCell', () => {
@@ -1,4 +1,6 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { PriceFlashCell } from './price-flash-cell';
describe('<PriceFlashCell />', () => {
@@ -1,49 +0,0 @@
import { render, screen } from '@testing-library/react';
import { VolCell, VolumeType } from './vol-cell';
import * as tailwind from '@vegaprotocol/tailwindcss-config';
describe('VolCell', () => {
const significantPart = '12,345';
const decimalPart = '67';
const props = {
value: 1234567,
valueFormatted: `${significantPart}.${decimalPart}`,
type: VolumeType.ask,
testId: 'cell',
};
it('Displays formatted value', () => {
render(<VolCell {...props} />);
expect(screen.getByTestId(props.testId)).toHaveTextContent(
props.valueFormatted
);
expect(screen.getByText(decimalPart)).toBeInTheDocument();
expect(screen.getByText(decimalPart)).toHaveClass('opacity-60');
});
it('Displays 0', () => {
render(<VolCell {...props} value={0} valueFormatted="0.00" />);
expect(screen.getByTestId(props.testId)).toHaveTextContent('0.00');
});
it('Displays - if value is not a number', () => {
render(<VolCell {...props} value={null} valueFormatted="" />);
expect(screen.getByTestId(props.testId)).toHaveTextContent('-');
});
it('renders bid volume bar', () => {
render(<VolCell {...props} type={VolumeType.bid} />);
expect(screen.getByTestId('vol-bar')).toHaveClass('left-0'); // renders bid bars from the left
expect(screen.getByTestId('vol-bar')).toHaveStyle({
backgroundColor: tailwind.theme.colors.vega.green.DEFAULT,
});
});
it('renders ask volume bar', () => {
render(<VolCell {...props} type={VolumeType.ask} />);
expect(screen.getByTestId('vol-bar')).toHaveClass('right-0'); // renders ask bars from the right
expect(screen.getByTestId('vol-bar')).toHaveStyle({
backgroundColor: tailwind.theme.colors.vega.pink.DEFAULT,
});
});
});
+6 -7
View File
@@ -8,7 +8,7 @@ export enum VolumeType {
bid,
ask,
}
export interface VolCellProps {
export interface VolProps {
value: number | bigint | null | undefined;
valueFormatted: string;
relativeValue?: number;
@@ -17,21 +17,20 @@ export interface VolCellProps {
}
export interface IVolCellProps extends ICellRendererParams {
value: number | bigint | null | undefined;
valueFormatted: Omit<VolCellProps, 'value'>;
valueFormatted: Omit<VolProps, 'value'>;
}
export const BID_COLOR = tailwind.theme.colors.vega.green.DEFAULT;
export const ASK_COLOR = tailwind.theme.colors.vega.pink.DEFAULT;
export const VolCell = React.memo(
({ value, valueFormatted, relativeValue, type, testId }: VolCellProps) => {
export const Vol = React.memo(
({ value, valueFormatted, relativeValue, type, testId }: VolProps) => {
if ((!value && value !== 0) || isNaN(Number(value))) {
return <div data-testid={testId || 'vol'}>-</div>;
return <div data-testid="vol">-</div>;
}
return (
<div className="relative" data-testid={testId || 'vol'}>
<div
data-testid="vol-bar"
className={classNames(
'h-full absolute top-0 opacity-40 dark:opacity-100',
{
@@ -51,4 +50,4 @@ export const VolCell = React.memo(
}
);
VolCell.displayName = 'VolCell';
Vol.displayName = 'Vol';