2023-11-30 07:43:37 -08:00
|
|
|
import { describe, expect, it } from "@jest/globals";
|
2023-12-04 04:47:02 -08:00
|
|
|
import { RepositoriesBuilder } from "../../../src/infrastructure/repositories/RepositoriesBuilder";
|
2023-11-30 07:43:37 -08:00
|
|
|
import { configMock } from "../../mocks/configMock";
|
|
|
|
import {
|
|
|
|
EvmJsonRPCBlockRepository,
|
|
|
|
FileMetadataRepository,
|
|
|
|
PromStatRepository,
|
|
|
|
RateLimitedSolanaSlotRepository,
|
|
|
|
SnsEventRepository,
|
|
|
|
} from "../../../src/infrastructure/repositories";
|
|
|
|
|
|
|
|
describe("RepositoriesBuilder", () => {
|
|
|
|
it("should be throw error because dose not have any chain", async () => {
|
|
|
|
try {
|
|
|
|
// When
|
|
|
|
new RepositoriesBuilder(configMock([]));
|
|
|
|
} catch (e: Error | any) {
|
|
|
|
// Then
|
|
|
|
expect(e).toBeInstanceOf(Error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be throw error because dose not support test chain", async () => {
|
|
|
|
try {
|
|
|
|
// When
|
|
|
|
new RepositoriesBuilder(configMock(["test"]));
|
|
|
|
} catch (e) {
|
|
|
|
// Then
|
|
|
|
expect(e).toBeInstanceOf(Error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be return all repositories instances", async () => {
|
|
|
|
// When
|
2023-12-01 11:25:02 -08:00
|
|
|
const repos = new RepositoriesBuilder(
|
2023-12-04 10:00:48 -08:00
|
|
|
configMock([
|
|
|
|
"solana",
|
|
|
|
"ethereum",
|
|
|
|
"avalanche",
|
2023-12-05 07:49:19 -08:00
|
|
|
"oasis",
|
2023-12-04 10:00:48 -08:00
|
|
|
"fantom",
|
|
|
|
"karura",
|
|
|
|
"acala",
|
2023-12-05 07:49:19 -08:00
|
|
|
"klaytn",
|
|
|
|
"celo",
|
2023-12-04 10:00:48 -08:00
|
|
|
"optimism",
|
|
|
|
"base",
|
|
|
|
])
|
2023-12-01 11:25:02 -08:00
|
|
|
);
|
2023-11-30 07:43:37 -08:00
|
|
|
// Then
|
|
|
|
const job = repos.getJobsRepository();
|
|
|
|
expect(job).toBeTruthy();
|
|
|
|
|
|
|
|
expect(repos.getEvmBlockRepository("ethereum")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-04 04:24:36 -08:00
|
|
|
expect(repos.getEvmBlockRepository("avalanche")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-05 07:49:19 -08:00
|
|
|
expect(repos.getEvmBlockRepository("oasis")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-01 05:09:58 -08:00
|
|
|
expect(repos.getEvmBlockRepository("fantom")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-11-30 07:43:37 -08:00
|
|
|
expect(repos.getEvmBlockRepository("karura")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-01 11:25:02 -08:00
|
|
|
expect(repos.getEvmBlockRepository("acala")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-05 07:49:19 -08:00
|
|
|
expect(repos.getEvmBlockRepository("klaytn")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
|
|
|
expect(repos.getEvmBlockRepository("celo")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-12-04 10:00:48 -08:00
|
|
|
expect(repos.getEvmBlockRepository("optimism")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
|
|
|
expect(repos.getEvmBlockRepository("base")).toBeInstanceOf(EvmJsonRPCBlockRepository);
|
2023-11-30 07:43:37 -08:00
|
|
|
expect(repos.getMetadataRepository()).toBeInstanceOf(FileMetadataRepository);
|
|
|
|
expect(repos.getSnsEventRepository()).toBeInstanceOf(SnsEventRepository);
|
|
|
|
expect(repos.getStatsRepository()).toBeInstanceOf(PromStatRepository);
|
|
|
|
expect(repos.getSolanaSlotRepository()).toBeInstanceOf(RateLimitedSolanaSlotRepository);
|
|
|
|
});
|
|
|
|
});
|