@magic.batua/recharge
Version:
The Recharge module manages all the mobile prepaid, datacard and DTH recharge functionalities of the Magic Batua platform.
70 lines • 2.59 kB
JavaScript
;
//
// MobilePrepaid.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 MobilePrepaid_1 = require("../Source/Mobile/MobilePrepaid");
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 Prepaid ◊◊◊", function () {
this.timeout(10000);
it("Should fetch plans for +919981992727 correctly. Circle should be MP and operator Airtel.", async function () {
try {
let account = await MobilePrepaid_1.MobilePrepaid.GetPlans("9981992727", creds);
expect(account).to.have.property("circle").with.property("code").equal("MP");
expect(account).to.have.property("operator").with.property("name").equal("Airtel");
expect(account).to.have.property("plans").not.empty;
}
catch (exception) {
console.log(exception);
console.log(JSON.stringify(exception));
}
});
it("Should recharge my phone with Rs. 1", async function () {
try {
let info = await MobilePrepaid_1.MobilePrepaid.GetPlans("9981992727", creds);
let prepaid = new MobilePrepaid_1.MobilePrepaid(info, info.plans[4]);
let response = await prepaid.Recharge(creds, "abcdefgh");
expect(response).to.have.property("status").equal("Success");
}
catch (exception) {
console.log(exception);
console.log(JSON.stringify(exception));
}
});
// it("Should report status of recharge ID abcd as success.", async function() {
// try {
// let info = await MobileRecharge.CheckStatus(creds, "abcd")
// console.log(info)
// }
// catch(exception) {
// console.log(JSON.stringify(exception))
// }
// })
});
//# sourceMappingURL=MobilePrepaid.spec.js.map