UNPKG

@magic.batua/recharge

Version:

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

61 lines 2.08 kB
"use strict"; // // Datacard.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 Datacard_1 = require("../Source/Datacard"); 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("◊◊◊  Datacard Recharge ◊◊◊", function () { this.timeout(10000); it("Should fetch operators correctly.", async function () { try { let operators = await Datacard_1.Datacard.AllOperators(creds); expect(operators).to.not.be.empty; } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); it("Should recharge my TataSky with Rs. 20", async function () { try { let operators = await Datacard_1.Datacard.AllOperators(creds); let BSNL = Operator_1.Operator.WithCode("60", operators); let datacard = new Datacard_1.Datacard(BSNL, "1000285868", 20); let response = await datacard.Recharge(creds, "animesh.tatasky.test.1"); expect(response).to.have.property("status").equal("Success"); } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); }); //# sourceMappingURL=Datacard.spec.js.map