26 lines
827 B
TypeScript
26 lines
827 B
TypeScript
import { Connection, PublicKey } from "@solana/web3.js";
|
|
import DLMM from "@meteora-ag/dlmm";
|
|
|
|
// Mocking the whole DLMM module
|
|
jest.mock("@meteora-ag/dlmm");
|
|
|
|
describe("Meteora SDK Mock Test", () => {
|
|
it("should mock DLMM.create", async () => {
|
|
const mockPool = {
|
|
getActiveBin: jest.fn().mockResolvedValue({ binId: 100, price: "1.23" }),
|
|
};
|
|
(DLMM.create as jest.Mock).mockResolvedValue(mockPool);
|
|
|
|
const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
const poolAddress = new PublicKey(
|
|
"LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ"
|
|
);
|
|
|
|
const pool = await DLMM.create(connection, poolAddress);
|
|
const activeBin = await pool.getActiveBin();
|
|
|
|
expect(activeBin.binId).toBe(100);
|
|
expect(DLMM.create).toHaveBeenCalledWith(connection, poolAddress);
|
|
});
|
|
});
|