// SPDX-FileCopyrightText: © 2026 LEDGER SAS // SPDX-License-Identifier: Apache-2.0 import { Networks, Transaction as StellarSdkTransaction } from '@stellar/stellar-sdk' import { combine } from '../combine' jest.mock('@stellar/stellar-sdk', () => ({ Networks: { PUBLIC: 'PUBLIC', }, Transaction: jest.fn().mockImplementation(() => ({ addSignature: jest.fn(), toXDR: jest.fn().mockReturnValue('signed-xdr'), })), })) describe('combine', () => { it('throws when more than one signature is provided', () => { expect(() => combine('unsigned-xdr', ['sig0', 'sig1'], 'public-key')).toThrow( 'Stellar combine expects exactly one signature, got 2' ) }) it('creates a transaction, adds signature and returns xdr', () => { const result = combine('unsigned-xdr', ['signature'], 'public-key') expect(StellarSdkTransaction).toHaveBeenCalledWith('unsigned-xdr', Networks.PUBLIC) const txInstance = jest.mocked(StellarSdkTransaction).mock.results[0].value expect(txInstance.addSignature).toHaveBeenCalledWith('public-key', 'signature') expect(result).toBe('signed-xdr') }) })