UNPKG

node-transferto

Version:
343 lines (283 loc) 11 kB
var expect = require('chai').expect, transferto = require('../transferto.js'), request = require('request'), config = require('../config.js') describe('TransferTo API Tests', function () { beforeEach(function () { transfer = new transferto; }); describe('>Basic Init Tests', function () { describe('>>Ping TransferTo Test', function () { beforeEach(function () { url = transfer.geturl('ping'); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Call should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return Transaction successful', function () { expect(response.body).to.contain('error_txt=Transaction successful'); expect(response.body).to.contain('error_code=0'); }); }); describe('>>Reserve ID Test', function () { beforeEach(function () { url = transfer.geturl('reserve_id'); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Call should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('Call should return the Reserved ID', function () { expect(response.body).to.contain('reserved_id'); }); it ('API should return Transaction successful', function () { expect(response.body).to.contain('error_txt=Transaction successful'); expect(response.body).to.contain('error_code=0'); }); }); }); describe('>Simulation and TopUp Tests', function () { describe('>>Simulation Test', function () { beforeEach(function () { url = transfer.geturl('simulation',config.TestNumber); }); beforeEach(function (done) { this.timeout(600000) request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return Transaction successful', function () { expect(response.body).to.contain('error_txt=Transaction successful'); expect(response.body).to.contain('error_code=0'); }); }); describe('>>Live TopUp Test', function () { beforeEach(function () { url = transfer.geturl('simulation',config.TestNumber); }); beforeEach(function (done) { this.timeout(600000) request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return Transaction successful', function () { expect(response.body).to.contain('error_txt=Transaction successful'); expect(response.body).to.contain('error_code=0'); }); }); }); /* describe('##TransferTo Recommended Test with reserved ID', function () { beforeEach(function () { beforeEach(function () { url = transfer.geturl('reserve_id'); action = 'topup' }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; reservedId = response.body.match(/\d+/)[0] done(err); }); }); describe('>>PIN based Top-up (successful transaction)', function () { beforeEach(function () { number = '628123456710'; amount = '5000'; url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return Transaction successful', function () { expect(response.body).to.contain('error_txt=Transaction successful'); expect(response.body).to.contain('error_code=0'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); describe('>>PIN less Top-up (successful transaction)', function () { beforeEach(function () { number = '628123456770' amount = '5000' url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return Transaction successful', function () { expect(response.body).to.contain('error_txt=Transaction successful'); expect(response.body).to.contain('error_code=0'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); describe('>>Destination number is not a valid prepaid phone number', function () { beforeEach(function () { number = '628123456780'; amount = 5000 url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return : error_txt=Destination Account is not prepaid or not valid', function () { expect(response.body).to.contain('error_txt=Destination Account is not prepaid or not valid'); expect(response.body).to.contain('error_code=204'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); describe('>>Input value out of range or invalid product)', function () { beforeEach(function () { number = '628123456781'; amount = 20000; url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return : error_txt=Denomination not available', function () { expect(response.body).to.contain('error_txt=Denomination not available'); expect(response.body).to.contain('error_code=301'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); describe('>>Transaction refused by the operator)', function () { beforeEach(function () { number = '628123456790'; amount = 5000; url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return : error_txt=Topup refused', function () { expect(response.body).to.contain('error_txt=Topup refused'); expect(response.body).to.contain('error_code=214'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); describe('>>System not available, please retry later', function () { beforeEach(function () { number = '628123456798'; amount = 50000; url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return : error_txt=System not available. Please retry later.', function () { expect(response.body).to.contain('error_txt=System not available. Please retry later.'); expect(response.body).to.contain('error_code=998'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); describe('>>Unknown error, please contact support', function () { beforeEach(function () { number = '628123456799'; amount = 100000; url = transfer.geturl(action,number,amount,reservedId); }); beforeEach(function (done) { this.timeout(600000); request.get({url: url}, function (err, resp, body) { response = resp; done(err); }); }); it ('Should return StatusCode OK', function () { expect(response.statusCode).to.equal(200); }); it ('API should return : error_txt = Unknown error.', function () { expect(response.body).to.contain('error_txt=Unknown error.'); expect(response.body).to.contain('error_code=999'); }); it ('API should should have used reservedID and number', function () { expect(response.body).to.contain(reservedId); expect(response.body).to.contain(number); }); }); }); */ });