Skip to content

Commit

Permalink
test: feedback: use it.skip() for commented out test
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrdlt authored and kenodressel committed May 29, 2024
1 parent 9e87d1e commit 6b94847
Showing 1 changed file with 64 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Pair, PairLiquidityInfoHistory } from '@prisma/client';
import * as request from 'supertest';

import { OrderQueryEnum } from '@/api/api.model';
import { PairLiquidityInfoHistoryController } from '@/api/pair-liquidity-info-history/pair-liquidity-info-history.controller';
import { PairLiquidityInfoHistoryService } from '@/api/pair-liquidity-info-history/pair-liquidity-info-history.service';
import {
historyEntry1,
historyEntry3,
pair1,
pair2,
} from '@/test/mock-data/pair-liquidity-info-history-mock-data';

const mockPairLiquidityInfoHistoryService = {
getAllHistoryEntries: jest.fn(),
Expand Down Expand Up @@ -34,93 +41,63 @@ describe('PairLiquidityInfoHistoryController', () => {
});

// TODO fix with updated return
// it('should return history entries and use default values for empty params', async () => {
// // Mocks
// const historyEntry1: { pair: Pair } & PairLiquidityInfoHistory = {
// id: 1,
// pairId: 1,
// totalSupply: '2000148656239820912122563',
// reserve0: '950875688379385634428666',
// reserve1: '4208476309359648851631167',
// height: 912485,
// microBlockHash: 'mh_Tx43Gh3acudUNSUWihPcV1Se4XcoFK3aUFAtFZk2Z4Zv7igZs',
// microBlockTime: 1709027642807n,
// updatedAt: new Date('2024-03-20 17:04:51.625'),
// pair: {
// id: 1,
// address: 'ct_efYtiwDg4YZxDWE3iLPzvrjb92CJPvzGwriv4ZRuvuTDMNMb9',
// t0: 15,
// t1: 5,
// synchronized: true,
// },
// };
//
// const historyEntry2: { pair: Pair } & PairLiquidityInfoHistory = {
// id: 2,
// pairId: 3,
// totalSupply: '9954575303087659158151',
// reserve0: '20210309618736130321327',
// reserve1: '4903471477408475598460',
// height: 707395,
// microBlockHash: 'mh_2dUTfmwFc2ymeroB534giVwEvsa8d44Vf8SXtvy6GeHjdgQoHj',
// microBlockTime: 1671708830503n,
// updatedAt: new Date('2024-03-20 12:16:49.065'),
// pair: {
// id: 3,
// address: 'ct_22iY9F7hng23gN8awi4aGnLy54YSR41wztbqgQCquuLYvTiGcm',
// t0: 17,
// t1: 22,
// synchronized: true,
// },
// };
//
// mockPairLiquidityInfoHistoryService.getAllHistoryEntries.mockResolvedValue(
// [historyEntry1, historyEntry2],
// );
//
// // Call route
// const result = await request(app.getHttpServer()).get(
// '/history/liquidity',
// );
//
// // Assertions
// expect(
// mockPairLiquidityInfoHistoryService.getAllHistoryEntries,
// ).toHaveBeenCalledWith(
// 100,
// 0,
// OrderQueryEnum.asc,
// undefined,
// undefined,
// undefined,
// undefined,
// );
// expect(result.status).toBe(200);
// expect(result.body).toEqual([
// {
// pairAddress: historyEntry1.pair.address,
// liquidityInfo: {
// totalSupply: historyEntry1.totalSupply,
// reserve0: historyEntry1.reserve0,
// reserve1: historyEntry1.reserve1,
// },
// height: historyEntry1.height,
// microBlockHash: historyEntry1.microBlockHash,
// microBlockTime: historyEntry1.microBlockTime.toString(),
// },
// {
// pairAddress: historyEntry2.pair.address,
// liquidityInfo: {
// totalSupply: historyEntry2.totalSupply,
// reserve0: historyEntry2.reserve0,
// reserve1: historyEntry2.reserve1,
// },
// height: historyEntry2.height,
// microBlockHash: historyEntry2.microBlockHash,
// microBlockTime: historyEntry2.microBlockTime.toString(),
// },
// ]);
// });
it.skip('should return history entries and use default values for empty params', async () => {
// Mocks
const historyEntryWithPair1: { pair: Pair } & PairLiquidityInfoHistory = {
...historyEntry1,
pair: pair1,
};

const historyEntryWithPair2: { pair: Pair } & PairLiquidityInfoHistory = {
...historyEntry3,
pair: pair2,
};

mockPairLiquidityInfoHistoryService.getAllHistoryEntries.mockResolvedValue(
[historyEntryWithPair1, historyEntryWithPair2],
);

// Call route
const result = await request(app.getHttpServer()).get(
'/history/liquidity',
);

// Assertions
expect(
mockPairLiquidityInfoHistoryService.getAllHistoryEntries,
).toHaveBeenCalledWith(
100,
0,
OrderQueryEnum.asc,
undefined,
undefined,
undefined,
undefined,
);
expect(result.status).toBe(200);
expect(result.body).toEqual([
{
pairAddress: historyEntryWithPair1.pair.address,
liquidityInfo: {
reserve0: historyEntryWithPair1.reserve0,
reserve1: historyEntryWithPair1.reserve1,
},
height: historyEntryWithPair1.height,
microBlockHash: historyEntryWithPair1.microBlockHash,
microBlockTime: historyEntryWithPair1.microBlockTime.toString(),
},
{
pairAddress: historyEntryWithPair2.pair.address,
liquidityInfo: {
reserve0: historyEntryWithPair2.reserve0,
reserve1: historyEntryWithPair2.reserve1,
},
height: historyEntryWithPair2.height,
microBlockHash: historyEntryWithPair2.microBlockHash,
microBlockTime: historyEntryWithPair2.microBlockTime.toString(),
},
]);
});

it('should parse all query params correctly', async () => {
// Mocks
Expand Down

0 comments on commit 6b94847

Please sign in to comment.