REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 4.91 KB
Close
/home/byroehnu/.trash/node_modules11/flutterwave-node-v3/test/rave.transactions.test.js
Text
Base64
var transactions = require('../lib/rave.transactions'); var base = require('../lib/rave.base'); var Promise = require('bluebird'); var mocha = require('mocha'); var chai = require('chai'); var expect = chai.expect; var chaiAsPromised = require('chai-as-promised'); var dotenv = require('dotenv').config(); const sinon = require('sinon'); const sinonChai = require('sinon-chai'); chai.use(chaiAsPromised); chai.use(sinonChai); describe('#Rave Transactions Coverage', function () { const public_key = process.env.PUBLIC_KEY; const secret_key = process.env.SECRET_KEY; const ravebase = new base(public_key, secret_key); let trxInstance; beforeEach(() => { trxInstance = new transactions(ravebase); }); afterEach(() => { sinon.restore(); }); it('should successfully verify a payment', async function () { this.timeout(10000); const requestStub = sinon.stub(ravebase, 'request').resolves({ body: { // SDK service files often destructure { body } status: 'success', message: 'Transaction fetched successfully', data: { id: 4186265, status: 'successful' } } }); const payload = { id: 4186265 }; const resp = await trxInstance.verify(payload); expect(requestStub).to.have.been.calledOnce; expect(resp).to.have.property('status', 'success'); expect(resp).to.have.property('message', 'Transaction fetched successfully'); }); it('should successfully verify a payment by tx_ref (Covers 100% of rave.verify-by-txref.js)', async function () { this.timeout(10000); const verifyTransactionbyTxStub = sinon.stub(ravebase, 'request').resolves({ body: { status: 'success', message: 'Transaction fetched successfully', data: { id: 8415006, tx_ref: 'txref-DI0NzMx13', status: 'successful' } } }); const payload = { tx_ref: 'txref-DI0NzMx13', }; const resp = await trxInstance.verify_by_tx(payload); expect(verifyTransactionbyTxStub).to.have.been.calledOnce; expect(resp).to.have.property('status', 'success'); expect(resp.data).to.have.property('tx_ref', "txref-DI0NzMx13"); }); it('should successfully return transaction events', async function () { this.timeout(10000); const requestStub = sinon.stub(ravebase, 'request').resolves({ body: { status: 'success', message: 'Transaction events fetched', data: [{ note: 'Transaction Completed!', action: 'completion' }] } }); const payload = { id: 4417681 }; const resp = await trxInstance.event(payload); expect(requestStub).to.have.been.calledOnce; expect(resp.data[0]).to.have.property('note'); }); it('should successfully return transaction fee', async function () { this.timeout(10000); const requestStub = sinon.stub(ravebase, 'request').resolves({ body: { status: 'success', message: 'Charged fee', data: { charge_amount: 1000, fee: 14 } } }); const payload = { amount: 1000, currency: "NGN" }; const resp = await trxInstance.fee(payload); expect(requestStub).to.have.been.calledOnce; expect(resp.data).to.have.property('fee', 14); }); it('should successfully initiate a refund (Covers rave.refund.js)', async function () { const requestStub = sinon.stub(ravebase, 'request').resolves({ body: { status: 'success', message: 'Refund processed', data: { id: '12345', amount: 1000, status: 'completed' } } }); const payload = { id: '4186265', amount: 1000 }; const resp = await trxInstance.refund(payload); expect(requestStub).to.have.been.calledOnce; expect(resp).to.have.property('status', 'success'); }); it('should successfully resend webhooks (Covers rave.resend-hooks.js)', async function () { const requestStub = sinon.stub(ravebase, 'request').resolves({ body: { status: 'success', message: 'Hook resent successfully' } }); const payload = { id: 4186265 }; const resp = await trxInstance.resend_hooks(payload); expect(requestStub).to.have.been.calledOnce; expect(resp).to.have.property('status', 'success'); expect(resp).to.have.property('message', 'Hook resent successfully'); }); it('should successfully retrieve all transactions (Covers rave.retrieve.js)', async function () { const requestStub = sinon.stub(ravebase, 'request').resolves({ body: { status: 'success', message: 'Transactions fetched', data: [{ id: 1 }, { id: 2 }], meta: { page_info: { total: 2 } } } }); const payload = { from: '2023-01-01', to: '2023-01-31', page: '1' }; const resp = await trxInstance.fetch(payload); expect(requestStub).to.have.been.calledOnce; expect(resp).to.have.property('status', 'success'); expect(resp).to.have.property('message', 'Transactions fetched'); }); });
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 16
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
rave.bank.test.js
2.46 KB
lrw-r--r--
2026-02-21 00:53:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.beneficiaries.test.js
3.79 KB
lrw-r--r--
2026-02-21 00:53:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.bills.test.js
16.01 KB
lrw-r--r--
2026-02-21 00:53:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.card.charge.test.js
2.68 KB
lrw-r--r--
2026-02-21 00:54:00
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.charge.test.js
45.37 KB
lrw-r--r--
2026-02-21 00:54:00
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.ebills.test.js
3.29 KB
lrw-r--r--
2026-02-21 00:54:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.misc.test.js
3.97 KB
lrw-r--r--
2026-02-21 00:54:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.momo.test.js
26.99 KB
lrw-r--r--
2026-02-21 00:54:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.otp.test.js
2.44 KB
lrw-r--r--
2026-02-21 00:54:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.payment-plan.test.js
3.58 KB
lrw-r--r--
2026-02-21 00:54:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.settlements.test.js
1.63 KB
lrw-r--r--
2026-02-21 00:54:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.subscriptions.test.js
2.74 KB
lrw-r--r--
2026-02-21 00:54:20
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.tokenization.test.js
8.13 KB
lrw-r--r--
2026-02-21 00:54:20
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.transactions.test.js
4.91 KB
lrw-r--r--
2026-02-21 00:54:20
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.transfer.test.js
6.44 KB
lrw-r--r--
2026-02-21 00:54:20
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rave.virtualcards.test.js
2.21 KB
lrw-r--r--
2026-02-21 00:54:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).