chore: handle negative decimals - add a bunch of tests

This commit is contained in:
maciek
2023-08-31 14:18:07 +02:00
parent 824495e070
commit 685a7d6278
3 changed files with 53 additions and 0 deletions
+22
View File
@@ -7,6 +7,7 @@ import type { Trade } from './fills-data-provider';
import { FillsTable, getFeesBreakdown } from './fills-table';
import { generateFill } from './test-helpers';
import { marketOrder } from '@vegaprotocol/orders';
describe('FillsTable', () => {
let defaultFill: PartialDeep<Trade>;
@@ -215,6 +216,27 @@ describe('FillsTable', () => {
).toBeInTheDocument();
});
it('negative positionDecimalPoints should be properly rendered in size column', async () => {
const partyId = 'party-id';
const negativeDecimalPositionFill = generateFill({
...defaultFill,
market: {
...defaultFill.market,
positionDecimalPlaces: -4,
},
});
await act(async () => {
render(
<FillsTable partyId={partyId} rowData={[negativeDecimalPositionFill]} />
);
});
const sizeCell = screen
.getAllByRole('gridcell')
.find((c) => c.getAttribute('col-id') === 'size');
expect(sizeCell).toHaveTextContent('3,000,000,000');
});
describe('getFeesBreakdown', () => {
it('should return correct fees breakdown for a taker', () => {
const fees = {
@@ -164,6 +164,24 @@ describe('OrderListTable', () => {
);
});
it('negative positionDecimalPoints should be properly rendered in size column', async () => {
const localMarketOrder = {
...marketOrder,
size: '3000',
market: {
...marketOrder.market,
positionDecimalPlaces: -4,
},
};
await act(async () => {
render(generateJsx({ rowData: [localMarketOrder] }));
});
const cells = screen.getAllByRole('gridcell');
expect(cells[2]).toHaveTextContent('+30,000,000');
});
describe('amend cell', () => {
it('allows cancelling and editing for permitted orders', async () => {
const mockEdit = jest.fn();
@@ -201,6 +201,19 @@ describe('Positions', () => {
).not.toBeInTheDocument();
});
it('handle negative positionDecimalPlaces', async () => {
await renderComponent({
...singleRow,
openVolume: '-2000',
positionDecimalPlaces: -4,
});
const cells = screen.getAllByRole('gridcell');
const cell = cells[1];
expect(within(cell).getByTestId('stack-cell-primary')).toHaveTextContent(
'-20,000,000'
);
});
describe('PNLCell', () => {
const props = {
data: undefined,