UNPKG

@magic.batua/recharge

Version:

The Recharge module manages all the mobile prepaid, datacard and DTH recharge functionalities of the Magic Batua platform.

75 lines 2.58 kB
"use strict"; // // MobilePostpaid.spec.ts // Mobile Recharge // // Created on March 16, 2018 by Animesh Mishra <hello@animesh.ltd> // © 2018 Animesh Ltd. All Rights Reserved. // Object.defineProperty(exports, "__esModule", { value: true }); const Chai = require("chai"); const FileSystem = require("fs"); const YAML = require("js-yaml"); const MobilePostpaid_1 = require("../Source/Mobile/MobilePostpaid"); const Operator_1 = require("../Source/Operator"); const expect = Chai.expect; let creds; before(function () { let env; if (process.env.NodeEnv == "production") { creds = { baseURL: process.env.Rocket_RechargeURL, merchantKey: process.env.Rocket_Key, merchantID: process.env.Rocket_ID }; } else { env = YAML.safeLoad(FileSystem.readFileSync(".env", "utf8")); creds = { baseURL: env.Rocket_RechargeURL, merchantKey: env.Rocket_Key, merchantID: env.Rocket_ID }; } }); describe("◊◊◊  Mobile Postpaid ◊◊◊", function () { this.timeout(10000); it("Should fetch operators correctly", async function () { try { let operators = await MobilePostpaid_1.MobilePostpaid.GetOperators(creds); expect(operators).to.not.be.empty; } catch (exception) { console.log(exception); console.log(JSON.stringify(exception, null, 2)); } }); it("Should pay bill successfully", async function () { try { // Get operator let operators = await MobilePostpaid_1.MobilePostpaid.GetOperators(creds); let airtel = Operator_1.Operator.WithCode("28", operators); // Create a bill let bill = new MobilePostpaid_1.MobilePostpaid(airtel, "9981992727", 10); // Pay bill let response = await bill.Pay(creds); // Test expect(response).to.have.property("status").be.equal("Success"); } catch (exception) { console.log(exception); console.log(JSON.stringify(exception, null, 2)); } }); // it("Should report status correctly", async function() { // try { // let operators = await MobilePostpaid.GetOperators(creds) // expect(operators).to.not.be.empty // } // catch (exception) { // console.log(exception) // console.log(JSON.stringify(exception, null, 2)) // } // }) }); //# sourceMappingURL=MobilePostpaid.spec.js.map