UNPKG

@b1u3too/lotide

Version:

LHL Web Development Flex Program Project -- Helper function library inspired by lodash

23 lines (22 loc) 880 B
const assert = require('chai').assert; const findKeyByValue = require('../findKeyByValue'); describe("#findKeyByValue", () => { it("should return the key if the desired value is found", () => { const bestTVShowsByGenre = { sci_fi: "The Expanse", comedy: "Brooklyn Nine-Nine", drama: "The Wire" }; assert.strictEqual(findKeyByValue(bestTVShowsByGenre, "The Wire"), "drama"); assert.strictEqual(findKeyByValue(bestTVShowsByGenre, "The Expanse"), "sci_fi"); }); it("should return undefined if the desired value is not found", () => { const bestTVShowsByGenre = { sci_fi: "The Expanse", comedy: "Brooklyn Nine-Nine", drama: "The Wire" }; assert.strictEqual(findKeyByValue(bestTVShowsByGenre, "That '70s Show"), undefined); assert.strictEqual(findKeyByValue(bestTVShowsByGenre, ""), undefined); }); });