import { mergeContexts } from "./mergeContexts"; import { createContext } from ".."; const TestContext = createContext(); describe("mergeContexts tests", () => { it("when context not has in existing, should add it", () => { const newContexts = mergeContexts([], [{ context: TestContext, value: "TestContextValue" }]); expect(newContexts.length).toBe(1); expect(newContexts[0]).toEqual({ context: TestContext, value: "TestContextValue", }); }); it("when context already exists, should change it", () => { const newContexts = mergeContexts( [{ context: TestContext, value: "OldTestContextValue" }], [{ context: TestContext, value: "NewTestContextValue" }], ); expect(newContexts.length).toBe(1); expect(newContexts[0]).toEqual({ context: TestContext, value: "NewTestContextValue", }); }); });