chore(trading): show markets in opening auction in market selector (#3814)
This commit is contained in:
parent
69c6db8ec2
commit
de637fee13
@ -10,6 +10,7 @@ import type { SortType } from './sort-dropdown';
|
||||
import { SortTypeMapping } from './sort-dropdown';
|
||||
import { Sort } from './sort-dropdown';
|
||||
import { subDays } from 'date-fns';
|
||||
import { isMarketActive } from './use-market-selector-list';
|
||||
|
||||
jest.mock('@vegaprotocol/market-list');
|
||||
const mockUseMarketList = useMarketList as jest.Mock;
|
||||
@ -126,9 +127,7 @@ describe('MarketSelector', () => {
|
||||
}),
|
||||
];
|
||||
|
||||
const activeMarkets = markets.filter((m) =>
|
||||
[MarketState.STATE_ACTIVE, MarketState.STATE_SUSPENDED].includes(m.state)
|
||||
);
|
||||
const activeMarkets = markets.filter((m) => isMarketActive(m.state));
|
||||
mockUseMarketList.mockReturnValue({
|
||||
data: markets,
|
||||
loading: false,
|
||||
|
@ -1,6 +1,9 @@
|
||||
import merge from 'lodash/merge';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { useMarketSelectorList } from './use-market-selector-list';
|
||||
import {
|
||||
isMarketActive,
|
||||
useMarketSelectorList,
|
||||
} from './use-market-selector-list';
|
||||
import { Product } from './product-selector';
|
||||
import { Sort } from './sort-dropdown';
|
||||
import { createMarketFragment } from '@vegaprotocol/mock';
|
||||
@ -38,6 +41,10 @@ describe('useMarketSelectorList', () => {
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-3',
|
||||
state: MarketState.STATE_CLOSED,
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-4',
|
||||
state: MarketState.STATE_PENDING,
|
||||
}),
|
||||
];
|
||||
@ -48,7 +55,7 @@ describe('useMarketSelectorList', () => {
|
||||
});
|
||||
const { result } = setup();
|
||||
const expectedFilteredMarkets = markets.filter((m) =>
|
||||
[MarketState.STATE_ACTIVE, MarketState.STATE_SUSPENDED].includes(m.state)
|
||||
isMarketActive(m.state)
|
||||
);
|
||||
expect(result.current).toEqual({
|
||||
data: markets,
|
||||
|
@ -18,11 +18,7 @@ export const useMarketSelectorList = ({
|
||||
if (!data?.length) return [];
|
||||
const markets = data
|
||||
// only active
|
||||
.filter((m) => {
|
||||
return [MarketState.STATE_ACTIVE, MarketState.STATE_SUSPENDED].includes(
|
||||
m.state
|
||||
);
|
||||
})
|
||||
.filter((m) => isMarketActive(m.state))
|
||||
// only selected product type
|
||||
.filter((m) => {
|
||||
if (m.tradableInstrument.instrument.product.__typename === product) {
|
||||
@ -80,3 +76,11 @@ export const useMarketSelectorList = ({
|
||||
|
||||
return { markets, data, loading, error };
|
||||
};
|
||||
|
||||
export const isMarketActive = (state: MarketState) => {
|
||||
return [
|
||||
MarketState.STATE_ACTIVE,
|
||||
MarketState.STATE_SUSPENDED,
|
||||
MarketState.STATE_PENDING,
|
||||
].includes(state);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user