UNPKG

@magic.batua/utility

Version:

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

67 lines 2.24 kB
"use strict"; // // Insurance.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 Insurance_1 = require("../Source/Insurance"); 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("◊◊◊  Insurance ◊◊◊", function () { this.timeout(10000); it("Should fetch providers correctly.", async function () { try { let providers = await Insurance_1.Insurance.GetProviders(creds); expect(providers).to.not.be.empty; } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); it("Should pay my Insurance bill", async function () { try { // Get provider let providers = await Insurance_1.Insurance.GetProviders(creds); let prudential = Provider_1.Provider.WithCode("IPI", providers); // Create a bill let bill = new Insurance_1.Insurance(prudential, "9277964000", "19-05-1993", 10); // Test #1 expect(bill.amount).to.equal(10); // Pay let utilityBill = await bill.Pay(creds); // Test #2 expect(utilityBill).to.have.property("status").equal("Success"); } catch (exception) { console.log(exception); console.log(JSON.stringify(exception)); } }); }); //# sourceMappingURL=Insurance.spec.js.map