Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mscolnick committed Sep 20, 2023
1 parent 52baf78 commit 3820b74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions frontend/src/editor/chrome/wrapper/__tests__/storage.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/* Copyright 2023 Marimo. All rights reserved. */
import Cookies from "js-cookie";
import { beforeEach, expect, describe, it } from "vitest";
import { createStorage } from "../storage";

describe("createStorage", () => {
beforeEach(() => {
Cookies.remove("test");
createStorage("left").setItem("test", "");
});

it("should store and retrieve items correctly when location is left", () => {
const storage = createStorage("left");
const value = JSON.stringify({ key: [1, 2] });

storage.setItem("test", value);
expect(Cookies.get("test")).toEqual(value);

const retrieved = storage.getItem("test");
expect(retrieved).toEqual(value);
Expand All @@ -22,10 +20,8 @@ describe("createStorage", () => {
it("should store and retrieve items correctly when location is bottom", () => {
const storage = createStorage("bottom");
const value = JSON.stringify({ key: [1, 2] });
const reversedValue = JSON.stringify({ key: [2, 1] });

storage.setItem("test", value);
expect(Cookies.get("test")).toEqual(reversedValue);

const retrieved = storage.getItem("test");
expect(retrieved).toEqual(value);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/editor/chrome/wrapper/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function createStorage(location: "left" | "bottom"): PanelGroupStorage {
}
}

storedValue = value;
storedValue = value || null;
},
};
}

0 comments on commit 3820b74

Please sign in to comment.