UNPKG

@ledgerhq/coin-tezos

Version:
31 lines 1.08 kB
import { createFixtureOperation } from "../types/bridge.fixture"; import config from "../config"; import { broadcast } from "./broadcast"; import { mockConfig } from "../test/config"; const mockInjectOperation = jest.fn(); jest.mock("@taquito/taquito", () => ({ TezosToolkit: jest.fn().mockReturnValue({ rpc: { injectOperation: () => mockInjectOperation(), }, }), })); describe("broadcast", () => { beforeAll(() => { config.setCoinConfig(() => mockConfig); }); it("calls 'injectOperation' from TezosToolkit and returns its hash computation", async () => { // GIVEN const signedOperation = { operation: createFixtureOperation(), signature: "SIGNATURE", }; mockInjectOperation.mockResolvedValue("SIGN_HASH"); // WHEN const op = await broadcast({ signedOperation, account: {} }); // THEN expect(mockInjectOperation).toHaveBeenCalledTimes(1); expect(op.hash).toEqual("SIGN_HASH"); }); }); //# sourceMappingURL=broadcast.test.js.map