UNPKG

@iam4x/bsc-scan

Version:

An efficient BNB and token balance scanner

2 lines 870 B
"use strict";var _bignumber=require("@ethersproject/bignumber"),_batch=require("./batch");describe("chunk",()=>{const a=["foo","bar","baz","qux"];it("should create chunks of an array",()=>{const b=(0,_batch.chunk)(a,2);expect(b).toHaveLength(2),expect(b[0][0]).toBe("foo"),expect(b[1][0]).toBe("baz")}),it("should keep uneven items",()=>{const b=(0,_batch.chunk)(a,3);expect(b).toHaveLength(2),expect(b[0]).toHaveLength(3),expect(b[1]).toHaveLength(1)})}),describe("batch",()=>{it("should batch function calls",async()=>{const a=jest.fn().mockImplementation(async(a)=>a.map(()=>_bignumber.BigNumber.from(1))),b=await(0,_batch.batch)(a,2,["0x0","0x1","0x2","0x3"]);expect(b).toHaveLength(4),expect(a).toHaveBeenCalledTimes(2),expect(a).toHaveBeenNthCalledWith(1,["0x0","0x1"]),expect(a).toHaveBeenNthCalledWith(2,["0x2","0x3"])})}); //# sourceMappingURL=batch.test.js.map