UNPKG

@ledgerhq/coin-stellar

Version:
47 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const broadcast_1 = require("./broadcast"); const bridge_fixture_1 = require("../types/bridge.fixture"); const mockBroadcast = jest.fn(); jest.mock("../network", () => ({ broadcastTransaction: (sig) => mockBroadcast(sig), })); describe("broadcast", () => { beforeEach(() => mockBroadcast.mockClear()); it("calls network apiNetwork", async () => { // When await (0, broadcast_1.broadcast)({ account: (0, bridge_fixture_1.createFixtureAccount)(), signedOperation: { signature: "Whatever signature", operation: (0, bridge_fixture_1.createFixtureOperation)(), }, }); // Then expect(mockBroadcast).toHaveBeenCalledTimes(1); expect(mockBroadcast.mock?.lastCall[0]).toEqual("Whatever signature"); }); it("returns a new operation with 'hash' setted and new id", async () => { // Given const operation = (0, bridge_fixture_1.createFixtureOperation)(); mockBroadcast.mockResolvedValue("Any hash value"); // When const newOperation = await (0, broadcast_1.broadcast)({ account: (0, bridge_fixture_1.createFixtureAccount)(), signedOperation: { signature: "Whatever signature", operation, }, }); // Then expect(newOperation).toEqual({ ...operation, id: expect.any(String), hash: "Any hash value", nftOperations: [], subOperations: [], }); expect(newOperation.id).not.toEqual(operation.id); }); }); //# sourceMappingURL=broadcast.test.js.map