UNPKG

@magic.batua/utility

Version:

The Utility module manages all the utility bills functionalities of the Magic Batua platform.

76 lines 2.77 kB
"use strict"; // // Electricity.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 Electricity_1 = require("../Source/Electricity"); 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("◊◊◊  Electricity ◊◊◊", function () { this.timeout(10000); it("Should fetch providers correctly.", async function () { try { let providers = await Electricity_1.Electricity.GetProviders(creds); expect(providers).to.not.be.empty; } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); it("Should fetch my electricity bill correctly.", async function () { try { let providers = await Electricity_1.Electricity.GetProviders(creds); let madhyaKshetra = Provider_1.Provider.WithCode("MME", providers); let bill = new Electricity_1.Electricity(madhyaKshetra, "9277964000"); bill.amount = await bill.Validate(creds); expect(bill.amount).to.equal(1414); } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); it("Should pay my Electricity bill", async function () { try { let providers = await Electricity_1.Electricity.GetProviders(creds); let madhyaKshetra = Provider_1.Provider.WithCode("MME", providers); let bill = new Electricity_1.Electricity(madhyaKshetra, "9277964000"); bill.amount = await bill.Validate(creds); expect(bill.amount).to.equal(1414); let utilityBill = await bill.Pay(creds, bill.amount); expect(utilityBill).to.have.property("status").equal("Success"); } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); }); //# sourceMappingURL=Electricity.spec.js.map