UNPKG

usda-ingredients-api

Version:

A library that makes REST requests against the USDA API to pull ingredients for food products

18 lines (17 loc) 653 B
const assert = require("assert"); const usda = require("../"); describe("USDA Tests", () => { it("should lookup ingredients for UPC 815893000163", async () => { const results = await usda("815893000163"); assert.ok(results); assert.strictEqual(results.length > 0, true); assert.strictEqual(results[0].gtinUpc, "815893000163") }); it("should fail because search brings back no results", async () => { try { await usda("a3453f1231g13sdgh"); } catch (error) { assert.strictEqual(error, "Unable to find food with search criteria: a3453f1231g13sdgh"); } }); });