first commit
This commit is contained in:
25
tests/integration/meteora_mock.test.ts
Normal file
25
tests/integration/meteora_mock.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user