UNPKG

xero-hero

Version:

Heroic utilities to simplify and enable your progress with the [xero-node](https://www.npmjs.com/package/xero-node) SDK.

97 lines (88 loc) 3.97 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // src/accounting/journals/__tests__/links.test.ts var import_xero_node = require("xero-node"); // src/common/instance/operations.ts var import_deep_cuts = require("deep-cuts"); // src/accounting/attachments/requests.ts var import_tranquil_stream = require("tranquil-stream"); // src/accounting/contacts/links.ts var import_qs = __toESM(require("qs")); // src/utils/properties.ts var hasProperty = (object, property) => { if (Boolean(object) && typeof object === "object") { return property in object; } return false; }; // src/accounting/invoices/lineItems.ts var import_deep_cuts2 = require("deep-cuts"); // src/accounting/journals/links.ts var import_qs2 = __toESM(require("qs")); var getManualJournalLink = (manualJournal) => { return `https://go.xero.com/Journal/View.aspx?${import_qs2.default.stringify({ invoiceID: (hasProperty(manualJournal, "manualJournalID") ? manualJournal.manualJournalID : manualJournal) || "null-or-empty-manual-journal-id" })}`; }; // src/projects/timeEntries.ts var import_deep_cuts3 = require("deep-cuts"); // src/accounting/journals/__tests__/links.test.ts describe("journals/links", () => { describe("getManualJournalLink()", () => { it("returns a null indicator if passed undefined", () => { expect(getManualJournalLink()).toBe( "https://go.xero.com/Journal/View.aspx?invoiceID=null-or-empty-manual-journal-id" ); }); it("returns a null indicator if passed null", () => { expect(getManualJournalLink(null)).toBe( "https://go.xero.com/Journal/View.aspx?invoiceID=null-or-empty-manual-journal-id" ); }); it("returns a null indicator if passed an empty string", () => { expect(getManualJournalLink("")).toBe( "https://go.xero.com/Journal/View.aspx?invoiceID=null-or-empty-manual-journal-id" ); }); it("returns the correct URL for a manual journal object with an manualJournalID property", () => { const manualJournal = new import_xero_node.ManualJournal(); manualJournal.manualJournalID = "25OR6TO4"; expect(getManualJournalLink(manualJournal)).toBe( "https://go.xero.com/Journal/View.aspx?invoiceID=25OR6TO4" ); }); it("returns the correct URL for a string manual journal ID", () => { expect(getManualJournalLink("sdfhj-47629-sjdgdd")).toBe( "https://go.xero.com/Journal/View.aspx?invoiceID=sdfhj-47629-sjdgdd" ); }); it("should work with an object that matches the interface for having a manualJournalID property", () => { const manualJournal = { manualJournalID: "25OR6TO4" }; expect(getManualJournalLink(manualJournal)).toBe( "https://go.xero.com/Journal/View.aspx?invoiceID=25OR6TO4" ); }); }); }); //# sourceMappingURL=links.test.js.map