UNPKG

@langchain/community

Version:
18 lines (17 loc) 631 B
import { test, expect, jest } from "@jest/globals"; import { insecureHash } from "@langchain/core/utils/hash"; import { RedisCache } from "../ioredis.js"; const sha1 = (str) => insecureHash(str); test("RedisCache", async () => { const redis = { get: jest.fn(async (key) => { if (key === sha1("foo_bar_0")) { return JSON.stringify({ text: "baz" }); } return null; }), }; // eslint-disable-next-line @typescript-eslint/no-explicit-any const cache = new RedisCache(redis); expect(await cache.lookup("foo", "bar")).toEqual([{ text: "baz" }]); });