Skip to content

Commit

Permalink
refactor: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-deriv committed Aug 5, 2024
1 parent 25c4fbb commit f1b8054
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const PositionsContent = observer(({ hasButtonsDemo, isClosedTab, setHasButtonsD
onMount: onClosedTabMount,
onUnmount: onClosedTabUnmount,
} = useReportsStore().profit_table;
// console.log('data', data);
const closedPositions = React.useMemo(() => data.map(d => ({ contract_info: d })), [data]);
const positions = React.useMemo(
() => (isClosedTab ? closedPositions : active_positions),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,39 @@ describe('PositionsStore', () => {
expect(mockedPositionsStore.customTimeRangeFilter).toEqual('');
});
});
describe('setDateFrom', () => {
it('should set dateFrom', () => {
mockedPositionsStore.setDateFrom(123424262);
expect(mockedPositionsStore.dateFrom).toEqual(123424262);
mockedPositionsStore.setDateFrom(null);
expect(mockedPositionsStore.dateFrom).toEqual(null);
});
});
describe('setDateTo', () => {
it('should set dateTo', () => {
mockedPositionsStore.setDateTo(12346779);
expect(mockedPositionsStore.dateTo).toEqual(12346779);
mockedPositionsStore.setDateTo(null);
expect(mockedPositionsStore.dateTo).toEqual(null);
});
});
describe('onUnmount', () => {
it('should reset all filters, when onUnmount is called', () => {
mockedPositionsStore.setDateTo(12346779);
mockedPositionsStore.setDateFrom(123424262);
mockedPositionsStore.setCustomTimeRangeFilter('25 May 2024');
mockedPositionsStore.setTimeFilter('All time');
mockedPositionsStore.setOpenContractTypeFilter(['Rise/Fall']);
mockedPositionsStore.setClosedContractTypeFilter(['Accumulators']);

mockedPositionsStore.onUnmount();

expect(mockedPositionsStore.dateTo).toEqual(null);
expect(mockedPositionsStore.dateFrom).toEqual(null);
expect(mockedPositionsStore.customTimeRangeFilter).toEqual('');
expect(mockedPositionsStore.timeFilter).toEqual('');
expect(mockedPositionsStore.openContractTypeFilter).toEqual([]);
expect(mockedPositionsStore.closedContractTypeFilter).toEqual([]);
});
});
});

0 comments on commit f1b8054

Please sign in to comment.