дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Watches were one list shared by every project, so a watch added while debugging one project showed up, and usually failed to evaluate, in all the others. Each project now keeps its own list; a project without one starts from the old shared list once, since that list doesn't record which project each watch came from. Co-authored-by: ntbang0901 <[email protected]>
50 рядки
1.4 KiB
TypeScript
50 рядки
1.4 KiB
TypeScript
import { beforeEach, describe, expect, it } from "vitest";
|
|
import { addWatch, loadWatches, useDebug } from "../state";
|
|
|
|
const SHARED = "openidea.debugger.watches";
|
|
const of = (root: string) => `${SHARED}:${root}`;
|
|
const watches = () => useDebug.getState().watches;
|
|
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
loadWatches(null);
|
|
});
|
|
|
|
describe("watch storage", () => {
|
|
it("loads a project's own watches", () => {
|
|
localStorage.setItem(of("/a"), '["x"]');
|
|
loadWatches("/a");
|
|
expect(watches()).toEqual(["x"]);
|
|
});
|
|
|
|
it("starts a project from the shared list once", () => {
|
|
localStorage.setItem(SHARED, '["legacy"]');
|
|
loadWatches("/b");
|
|
expect(watches()).toEqual(["legacy"]);
|
|
expect(localStorage.getItem(of("/b"))).toBe('["legacy"]');
|
|
expect(localStorage.getItem(SHARED)).toBe('["legacy"]');
|
|
});
|
|
|
|
it("keeps projects apart", () => {
|
|
loadWatches("/a");
|
|
addWatch("y");
|
|
loadWatches("/b");
|
|
expect(watches()).not.toContain("y");
|
|
loadWatches("/a");
|
|
expect(watches()).toContain("y");
|
|
});
|
|
|
|
it("an emptied list stays empty", () => {
|
|
localStorage.setItem(SHARED, '["legacy"]');
|
|
localStorage.setItem(of("/a"), "[]");
|
|
loadWatches("/a");
|
|
expect(watches()).toEqual([]);
|
|
});
|
|
|
|
it("without a project nothing is stored", () => {
|
|
loadWatches(null);
|
|
addWatch("z");
|
|
expect(localStorage.length).toBe(0);
|
|
});
|
|
});
|