const app = require(`${servicesDir}/client/server/server`); describe('Client confirmTransaction', () => { const transactionId = 2; afterAll(async() => { await app.models.Client.rawSql(` CALL hedera.tpvTransactionUndo(?)`, [transactionId]); }); it('should call confirmTransaction() method and throw error for a non administrative person', async() => { let ctx = {req: {accessToken: {userId: 1}}}; let error; await app.models.Client.confirmTransaction(ctx, transactionId).catch(e => { error = e; }).finally(() => { expect(error.message).toEqual(`You don't have enough privileges to do that`); }); }); it('should call confirmTransaction() method to mark transaction as confirmed', async() => { let ctx = {req: {accessToken: {userId: 5}}}; await app.models.Client.confirmTransaction(ctx, transactionId); let [receipt] = await app.models.Client.rawSql( `SELECT receiptFk FROM hedera.tpvTransaction WHERE id = ?`, [transactionId]); expect(receipt.receiptFk).toBeGreaterThan(0); }); });