|
| 1 | +import { dialog } from 'electron' |
1 | 2 | import { CKBComponents } from '@ckb-lumos/lumos/rpc' |
2 | 3 | import { bytes } from '@ckb-lumos/lumos/codec' |
3 | 4 | import 'dotenv/config' |
@@ -181,6 +182,12 @@ jest.doMock('services/cells', () => ({ |
181 | 182 | getLiveCell: stubbedGetLiveCell, |
182 | 183 | })) |
183 | 184 |
|
| 185 | +jest.mock('electron', () => ({ |
| 186 | + dialog: { |
| 187 | + showMessageBox: jest.fn(), |
| 188 | + }, |
| 189 | +})) |
| 190 | + |
184 | 191 | import Transaction from '../../../src/models/chain/transaction' |
185 | 192 | import TxStatus from '../../../src/models/chain/tx-status' |
186 | 193 | import CellDep, { DepType } from '../../../src/models/chain/cell-dep' |
@@ -1001,13 +1008,28 @@ describe('TransactionSender Test', () => { |
1001 | 1008 | }) |
1002 | 1009 | }) |
1003 | 1010 |
|
1004 | | - it('throw exception no matched multisig config', async () => { |
| 1011 | + it('no matched multisig config, ignore and continue', async () => { |
| 1012 | + const showMessageBoxMock = jest |
| 1013 | + .spyOn(dialog, 'showMessageBox') |
| 1014 | + .mockImplementation(() => Promise.resolve({ response: 1, checkboxChecked: true })) |
| 1015 | + mockGAI.mockReturnValueOnce([{ path: '' }]) |
| 1016 | + transactionSender.getAddressInfos = mockGAI.bind(transactionSender) |
| 1017 | + const tx = Transaction.fromObject(transactionObject) |
| 1018 | + await expect(transactionSender.signMultisig(fakeWallet.id, tx, '1234', [])).resolves.not.toThrow() |
| 1019 | + expect(showMessageBoxMock).toHaveBeenCalled() |
| 1020 | + }) |
| 1021 | + |
| 1022 | + it('no matched multisig config, throw exception', async () => { |
| 1023 | + const showMessageBoxMock = jest |
| 1024 | + .spyOn(dialog, 'showMessageBox') |
| 1025 | + .mockImplementation(() => Promise.resolve({ response: 0, checkboxChecked: false })) |
1005 | 1026 | mockGAI.mockReturnValueOnce([{ path: '' }]) |
1006 | 1027 | transactionSender.getAddressInfos = mockGAI.bind(transactionSender) |
1007 | 1028 | const tx = Transaction.fromObject(transactionObject) |
1008 | 1029 | await expect(transactionSender.signMultisig(fakeWallet.id, tx, '1234', [])).rejects.toThrowError( |
1009 | 1030 | new MultisigConfigNeedError() |
1010 | 1031 | ) |
| 1032 | + expect(showMessageBoxMock).toHaveBeenCalled() |
1011 | 1033 | }) |
1012 | 1034 |
|
1013 | 1035 | it('throw exception no matched multisig config addresses', async () => { |
|
0 commit comments