UNPKG

@magic.batua/recharge

Version:

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

81 lines 2.67 kB
"use strict"; // // Fixedline.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 Fixedline_1 = require("../Source/Fixedline"); 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("◊◊◊  Fixedline ◊◊◊", function () { this.timeout(10000); it("Should fetch operators correctly", async function () { try { let operators = await Fixedline_1.Fixedline.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 Fixedline_1.Fixedline.GetOperators(creds); let airtel = Operator_1.Operator.WithCode("30", operators); // Create a bill let billInfo = { operator: airtel, std: "755", phone: "4921591", amount: 10 }; let bill = new Fixedline_1.Fixedline(billInfo); // 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=Fixedline.spec.js.map