From f41dcbc101c9fb1abc1de462c21b4d2a52ce717d Mon Sep 17 00:00:00 2001 From: Timo Erdelt Date: Mon, 19 Aug 2024 15:32:29 +0200 Subject: [PATCH] test: fix pair-sync.service.e2e-spec.ts --- .../e2e/__snapshots__/tokens.e2e-spec.ts.snap | 62 ++++++++++++++++--- test/e2e/jest-e2e.json | 2 +- test/e2e/pair-sync.service.e2e-spec.ts | 16 +++++ test/e2e/tokens.e2e-spec.ts | 5 +- 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/test/e2e/__snapshots__/tokens.e2e-spec.ts.snap b/test/e2e/__snapshots__/tokens.e2e-spec.ts.snap index 962b049c..5bd5661d 100644 --- a/test/e2e/__snapshots__/tokens.e2e-spec.ts.snap +++ b/test/e2e/__snapshots__/tokens.e2e-spec.ts.snap @@ -8,7 +8,7 @@ exports[`TokenController DELETE /tokens/listed/{token_address} should return 200 "malformed": false, "name": "3", "noContract": false, - "pairs": 2, + "pairs": 1, "priceAe": null, "priceChangeDay": null, "priceChangeMonth": null, @@ -47,7 +47,7 @@ exports[`TokenController DELETE /tokens/listed/{token_address} should return 200 "malformed": false, "name": "3", "noContract": false, - "pairs": 2, + "pairs": 1, "priceAe": null, "priceChangeDay": null, "priceChangeMonth": null, @@ -123,7 +123,7 @@ exports[`TokenController GET /tokens should return all tokens even if some are l "malformed": false, "name": "3", "noContract": false, - "pairs": 2, + "pairs": 1, "priceAe": null, "priceChangeDay": null, "priceChangeMonth": null, @@ -140,6 +140,30 @@ exports[`TokenController GET /tokens should return all tokens even if some are l "volumeUsdWeek": "0", "volumeUsdYear": "0", }, + { + "address": "ct_token5", + "decimals": 18, + "listed": false, + "malformed": false, + "name": "5", + "noContract": false, + "pairs": 1, + "priceAe": null, + "priceChangeDay": null, + "priceChangeMonth": null, + "priceChangeWeek": null, + "priceChangeYear": null, + "priceUsd": null, + "symbol": "5", + "totalReserve": null, + "tvlAe": null, + "tvlUsd": null, + "volumeUsdAll": null, + "volumeUsdDay": null, + "volumeUsdMonth": null, + "volumeUsdWeek": null, + "volumeUsdYear": null, + }, ] `; @@ -200,7 +224,7 @@ exports[`TokenController GET /tokens should return all tokens when none are list "malformed": false, "name": "3", "noContract": false, - "pairs": 2, + "pairs": 1, "priceAe": null, "priceChangeDay": null, "priceChangeMonth": null, @@ -217,6 +241,30 @@ exports[`TokenController GET /tokens should return all tokens when none are list "volumeUsdWeek": "0", "volumeUsdYear": "0", }, + { + "address": "ct_token5", + "decimals": 18, + "listed": false, + "malformed": false, + "name": "5", + "noContract": false, + "pairs": 1, + "priceAe": null, + "priceChangeDay": null, + "priceChangeMonth": null, + "priceChangeWeek": null, + "priceChangeYear": null, + "priceUsd": null, + "symbol": "5", + "totalReserve": null, + "tvlAe": null, + "tvlUsd": null, + "volumeUsdAll": null, + "volumeUsdDay": null, + "volumeUsdMonth": null, + "volumeUsdWeek": null, + "volumeUsdYear": null, + }, ] `; @@ -278,13 +326,13 @@ exports[`TokenController GET /tokens/{token_address}/pairs should return pairs w "totalSupply": "2", }, "oppositeToken": { - "address": "ct_token3", + "address": "ct_token5", "decimals": 18, "listed": false, "malformed": false, - "name": "3", + "name": "5", "noContract": false, - "symbol": "3", + "symbol": "5", }, "synchronized": true, }, diff --git a/test/e2e/jest-e2e.json b/test/e2e/jest-e2e.json index cf7b89b9..70f03f71 100644 --- a/test/e2e/jest-e2e.json +++ b/test/e2e/jest-e2e.json @@ -2,7 +2,7 @@ "moduleFileExtensions": ["js", "json", "ts"], "rootDir": "../", "testEnvironment": "node", - "testRegex": "pairs.e2e-spec.ts$", + "testRegex": "e2e-spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, diff --git a/test/e2e/pair-sync.service.e2e-spec.ts b/test/e2e/pair-sync.service.e2e-spec.ts index a1c5cddd..8eefdb7a 100644 --- a/test/e2e/pair-sync.service.e2e-spec.ts +++ b/test/e2e/pair-sync.service.e2e-spec.ts @@ -10,6 +10,14 @@ import { PairSyncService } from '@/tasks/pair-sync/pair-sync.service'; import * as data from '@/test/mock-data/context-mock-data'; import { mockContext } from '@/test/utils/context-mock'; import { cleanDb } from '@/test/utils/db-helper'; +import { PairLiquidityInfoHistoryImporterService } from '@/tasks/pair-liquidity-info-history-importer/pair-liquidity-info-history-importer.service'; +import { PairPathCalculatorService } from '@/tasks/pair-path-calculator/pair-path-calculator.service'; +import { PairLiquidityInfoHistoryDbService } from '@/database/pair-liquidity-info-history/pair-liquidity-info-history-db.service'; +import { PairLiquidityInfoHistoryErrorDbService } from '@/database/pair-liquidity-info-history-error/pair-liquidity-info-history-error-db.service'; +import { MdwHttpClientService } from '@/clients/mdw-http-client.service'; +import { HttpService } from '@/clients/http.service'; +import { CoinmarketcapClientService } from '@/clients/coinmarketcap-client.service'; +import { CacheModule } from '@nestjs/cache-manager'; // Testing method // 1. before all create a common context @@ -22,13 +30,21 @@ describe('PairSyncService', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ + imports: [CacheModule.register({})], providers: [ PairSyncService, PrismaService, TokenDbService, PairDbService, + HttpService, + CoinmarketcapClientService, + MdwHttpClientService, MdwWsClientService, SdkClientService, + PairLiquidityInfoHistoryImporterService, + PairLiquidityInfoHistoryDbService, + PairLiquidityInfoHistoryErrorDbService, + PairPathCalculatorService, ], }).compile(); diff --git a/test/e2e/tokens.e2e-spec.ts b/test/e2e/tokens.e2e-spec.ts index 473b73f7..4ae8cd7c 100644 --- a/test/e2e/tokens.e2e-spec.ts +++ b/test/e2e/tokens.e2e-spec.ts @@ -23,6 +23,7 @@ import { token1, token2, token3, + token5, } from '@/test/mock-data/pair-liquidity-info-history-mock-data'; // Testing method @@ -61,7 +62,9 @@ describe('TokenController', () => { }); beforeEach(async () => { - await prismaService.token.createMany({ data: [token1, token2, token3] }); + await prismaService.token.createMany({ + data: [token1, token2, token3, token5], + }); await prismaService.pair.createMany({ data: [pair1, pair2, pair3] }); await prismaService.pairLiquidityInfo.createMany({ data: [liquidityInfo1, liquidityInfo2],