@magic.batua/utility
Version:
The Utility module manages all the utility bills functionalities of the Magic Batua platform.
67 lines • 2.18 kB
JavaScript
;
//
// Gas.spec.ts
// Magic Utility
//
// 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 Gas_1 = require("../Source/Gas");
const Provider_1 = require("../Source/Provider");
const expect = Chai.expect;
let creds;
before(function () {
let env;
if (process.env.NodeEnv == "production") {
creds = {
baseURL: process.env.RIP_UtilityURL,
merchantKey: process.env.RIP_MerchantKey,
merchantID: process.env.RIP_MerchantID
};
}
else {
env = YAML.safeLoad(FileSystem.readFileSync(".env", "utf8"));
creds = {
baseURL: env.RIP_UtilityURL,
merchantKey: env.RIP_MerchantKey,
merchantID: env.RIP_MerchantID
};
}
});
describe("◊◊◊ Gas ◊◊◊", function () {
this.timeout(10000);
it("Should fetch providers correctly.", async function () {
try {
let providers = await Gas_1.Gas.GetProviders(creds);
expect(providers).to.not.be.empty;
}
catch (exception) {
console.log(exception);
console.log(JSON.stringify(exception));
}
});
it("Should pay my Gas bill", async function () {
try {
// Get provider
let providers = await Gas_1.Gas.GetProviders(creds);
let mahanagarGas = Provider_1.Provider.WithCode("MMG", providers);
// Create a bill
let bill = new Gas_1.Gas(mahanagarGas, "9277964000", 10);
// Test #1
expect(bill.amount).to.equal(10);
// Pay
let utilityBill = await bill.Pay(creds, false, { billGroup: "2" });
// Test #2
expect(utilityBill).to.have.property("status").equal("Success");
}
catch (exception) {
console.log(exception);
console.log(JSON.stringify(exception));
}
});
});
//# sourceMappingURL=Gas.spec.js.map