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 (87 loc) 3.67 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/invoices/__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/invoices/links.ts var getInvoiceLink = (invoice) => { return `https://invoicing.xero.com/view/${(hasProperty(invoice, "invoiceID") ? invoice.invoiceID : invoice) || "null-or-empty-invoice-id"}`; }; // src/accounting/journals/links.ts var import_qs2 = __toESM(require("qs")); // src/projects/timeEntries.ts var import_deep_cuts3 = require("deep-cuts"); // src/accounting/invoices/__tests__/links.test.ts describe("invoices/links", () => { describe("getInvoiceLink()", () => { it("returns a null indicator if passed undefined", () => { expect(getInvoiceLink()).toBe( "https://invoicing.xero.com/view/null-or-empty-invoice-id" ); }); it("returns a null indicator if passed null", () => { expect(getInvoiceLink(null)).toBe( "https://invoicing.xero.com/view/null-or-empty-invoice-id" ); }); it("returns a null indicator if passed an empty string", () => { expect(getInvoiceLink("")).toBe( "https://invoicing.xero.com/view/null-or-empty-invoice-id" ); }); it("returns the correct URL for an invoice object with an invoiceID property", () => { const invoice = new import_xero_node.Invoice(); invoice.invoiceID = "25OR6TO4"; expect(getInvoiceLink(invoice)).toBe( "https://invoicing.xero.com/view/25OR6TO4" ); }); it("returns the correct URL for a string invoice ID", () => { expect(getInvoiceLink("kooolaid-9086-t728")).toBe( "https://invoicing.xero.com/view/kooolaid-9086-t728" ); }); it("should work with an object that matches the interface for having a invoiceID property", () => { const invoice = { invoiceID: "25OR6TO4" }; expect(getInvoiceLink(invoice)).toBe( "https://invoicing.xero.com/view/25OR6TO4" ); }); }); }); //# sourceMappingURL=links.test.js.map